Coding Interview Prep
How coding interviews work, and the patterns behind most questions: hashing, two pointers, sliding windows, stacks, binary search, lists, trees, graphs, DP and backtracking.
- 1
How coding interviews work
The stages of a technical interview, what interviewers really judge, a six-step method for any problem, and how to talk about time and space complexity.
- 2
Arrays and hashing
Hash maps and sets turn O(n²) searches into O(n): two sum, counting with dictionaries and Counter, grouping anagrams, and prefix sums.
- 3
Two pointers
Two indexes moving through a sorted list or a string: pair sums, palindromes, removing duplicates in place, three sum, and the container with the most water.
- 4
Sliding windows
A window over a list or string that slides instead of restarting: fixed-size windows, the longest substring without repeats, and the smallest window that meets a condition.
- 5
Stacks and queues
Stacks for matching brackets and for monotonic-stack problems like the next greater element; queues and deques for breadth-first order and sliding-window maximums.
- 6
Binary search patterns
Binary search beyond 'find x': the first position that passes a test, searching a rotated list, and binary search on the answer itself.
- 7
Linked list patterns
Reversing a list in place, fast and slow pointers for the middle and for cycles (Floyd's algorithm), merging two sorted lists, and the dummy-head trick.
- 8
Tree patterns
Recursive depth-first answers built from the children's answers, breadth-first level order with a queue, validating a binary search tree, and the lowest common ancestor.
- 9
Graph patterns
Grids are graphs: counting islands with DFS or BFS, shortest paths in unweighted graphs with BFS, and ordering tasks with topological sort.
- 10
Heaps and intervals
Top-k problems with a heap (heapq), merging overlapping intervals after sorting, and counting meeting rooms by sweeping start and end times.
- 11
Dynamic programming patterns
Spot a DP problem, define the state and the recurrence, and solve it top-down with memoization or bottom-up with a table: climbing stairs, house robber, coin change and the longest increasing subsequence.
- 12
Backtracking
Build every solution one choice at a time and undo each choice afterwards: subsets, permutations, combination sum, and pruning branches that cannot succeed.
- 13
A mock interview, start to finish
One problem worked through the way a strong candidate does it, out loud, plus the behavioural round, your CV, and a plan for the weeks before your interviews.