Coding Interview Cheat Sheet



This is a straight-to-the-point, distilled list of technical interview Do's and Don'ts for interviewers, mainly for algorithmic interviews. Some of these may apply to only phone screens or whiteboard interviews, but most will apply to both. I revise this list before each of my interviews as an interviewer to remind myself of them and eventually internalized all of them to the point I do not. @Steve: thanks, not sure what you mean by Python's 'boatload of invocation options and environmental variables' — generally things work fine by typing 'python myprog.py' But in any case, the point of a cheat-sheet is to aid one's memory; most cheat-sheets presume the reader is already very comfortable with core concepts like control flow.

Java Programming Cheatsheet. We summarize the most commonly used Java language features and APIs in the textbook. Editing, compiling, and executing. Phases of a coding interview. Congratulations, you are ready to put your skills to practice! In a coding interview, you will be given a technical question by the interviewer. You will write the code in a real-time, collaborative editor (phone screen) or on a whiteboard (on-site), and have 30 to 45 minutes to solve the problem.


We summarize the most commonly used Java language features and APIs in the textbook.


Hello, World.


Editing, compiling, and executing.


Built-in data types.


Declaration and assignment statements.


Integers.

Software Engineering Interview Cheat Sheet


Floating-point numbers.


Booleans.


Comparison operators.


Printing.


Parsing command-line arguments.


Math library.

The full java.lang.Math API.


Java library calls.


Type conversion.


Anatomy of an if statement.


If and if-else statements.


Nested if-else statement.


Data Structure Cheat Sheet

Anatomy of a while loop.


Cheat

Anatomy of a for loop.


Loops.


Break statement.


Do-while loop.


Switch statement.


Arrays.

Inline array initialization.

Typical array-processing code.

Two-dimensional arrays.

Inline initialization.


Our standard output library.

Coding interview cheat sheet sampleThe full StdOut API.


Our standard input library.

The full StdIn API.


Our standard drawing library.

The full StdDraw API.


Our standard audio library.

The full StdAudio API.


Command line.


Redirection and piping.



Functions.


Libraries of functions.


Our standard random library.


Our standard statistics library.


Using an object.


Instance variables.


Constructors.


Instance methods.


Classes.


Object-oriented libraries.

Java's String data type.

The full java.lang.String API.

Coding Interview Cheat Sheet Printable

Java's Color data type.

The full java.awt.Color API.


Coding Interview Cheat Sheet

Our input library.

The full In API.


Our output library.

The full Out API.


Our picture library.

The full Picture API.


Our stack data type.

The full Stack API.


Our queue data type.

The full Queue API.


Iterable.


Our symbol table data type.

The full ST API.Interview


Our set data type.

The full SET API.


Our graph data type.

The full Graph API.


Compile-time and run-time errors.

Here's a list of errors compiled byMordechai Ben-Ari.It includes a list of common error message and typical mistakes thatgive rise to them.

Last modified on October 30, 2019.
Copyright © 2000–2019Robert SedgewickandKevin Wayne.All rights reserved.

Common Data Structure Operations

Data StructureTime ComplexitySpace Complexity
AverageWorstWorst
AccessSearchInsertionDeletionAccessSearchInsertionDeletion
ArrayΘ(1)Θ(n)Θ(n)Θ(n)O(1)O(n)O(n)O(n)O(n)
StackΘ(n)Θ(n)Θ(1)Θ(1)O(n)O(n)O(1)O(1)O(n)
QueueΘ(n)Θ(n)Θ(1)Θ(1)O(n)O(n)O(1)O(1)O(n)
Singly-Linked ListΘ(n)Θ(n)Θ(1)Θ(1)O(n)O(n)O(1)O(1)O(n)
Doubly-Linked ListΘ(n)Θ(n)Θ(1)Θ(1)O(n)O(n)O(1)O(1)O(n)
Skip ListΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(n)O(n)O(n)O(n)O(n log(n))
Hash TableN/AΘ(1)Θ(1)Θ(1)N/AO(n)O(n)O(n)O(n)
Binary Search TreeΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(n)O(n)O(n)O(n)O(n)
Cartesian TreeN/AΘ(log(n))Θ(log(n))Θ(log(n))N/AO(n)O(n)O(n)O(n)
B-TreeΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(log(n))O(log(n))O(log(n))O(log(n))O(n)
Red-Black TreeΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(log(n))O(log(n))O(log(n))O(log(n))O(n)
Splay TreeN/AΘ(log(n))Θ(log(n))Θ(log(n))N/AO(log(n))O(log(n))O(log(n))O(n)
AVL TreeΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(log(n))O(log(n))O(log(n))O(log(n))O(n)
KD TreeΘ(log(n))Θ(log(n))Θ(log(n))Θ(log(n))O(n)O(n)O(n)O(n)O(n)

Array Sorting Algorithms

AlgorithmTime ComplexitySpace Complexity
BestAverageWorstWorst
QuicksortΩ(n log(n))Θ(n log(n))O(n^2)O(log(n))
MergesortΩ(n log(n))Θ(n log(n))O(n log(n))O(n)
TimsortΩ(n)Θ(n log(n))O(n log(n))O(n)
HeapsortΩ(n log(n))Θ(n log(n))O(n log(n))O(1)
Bubble SortΩ(n)Θ(n^2)O(n^2)O(1)
Insertion SortΩ(n)Θ(n^2)O(n^2)O(1)
Selection SortΩ(n^2)Θ(n^2)O(n^2)O(1)
Tree SortΩ(n log(n))Θ(n log(n))O(n^2)O(n)
Shell SortΩ(n log(n))Θ(n(log(n))^2)O(n(log(n))^2)O(1)
Bucket SortΩ(n+k)Θ(n+k)O(n^2)O(n)
Radix SortΩ(nk)Θ(nk)O(nk)O(n+k)
Counting SortΩ(n+k)Θ(n+k)O(n+k)O(k)
CubesortΩ(n)Θ(n log(n))O(n log(n))O(n)