Coding interview prep
The 12 coding interview patterns
Most coding interview questions are variations on a small set of patterns. Learn to recognise the pattern and the solution writes itself. Each page below covers when to reach for the pattern, its time and space complexity, a worked walkthrough, a translatable skeleton, a curated problem set, and the mistakes that cost candidates the offer.
Why patterns beat grinding
Recognise, do not memorise
Solving five hundred random problems teaches you five hundred problems. Learning the dozen patterns underneath them teaches you to solve problems you have never seen, which is exactly what the interview tests. When you read a new question, scan for the tells: a contiguous-subarray ask points to sliding window, a sorted array points to two pointers or binary search, an all-configurations ask points to backtracking. Naming the pattern out loud is also a strong interview signal in its own right.
All patterns
Pick a pattern to master
- Sliding Window
Track a contiguous subarray or substring without re-scanning it from scratch.
6 practice problems - Two Pointers
Walk two indices toward or alongside each other to avoid a nested loop.
6 practice problems - Binary Search
Halve the search space each step over any monotonic condition, not just sorted arrays.
6 practice problems - Dynamic Programming
Solve overlapping subproblems once, store the results, and build the answer up.
6 practice problems - Breadth-First Search (BFS)
Explore level by level with a queue; the natural fit for shortest paths on unweighted graphs.
6 practice problems - Depth-First Search (DFS)
Go as deep as possible before backtracking; the backbone of tree and graph exploration.
6 practice problems - Backtracking
Build candidates incrementally and abandon a partial solution the moment it cannot work.
6 practice problems - Heap / Priority Queue
Keep the largest or smallest element instantly available without fully sorting.
6 practice problems - Trie (Prefix Tree)
Store strings by shared prefixes for fast prefix search and word lookup.
6 practice problems - Union-Find (Disjoint Set)
Track connectivity between elements with near-constant-time union and find.
6 practice problems - Greedy
Make the locally optimal choice at each step when it provably yields the global optimum.
6 practice problems - Merge Intervals
Sort by start, then sweep to merge, insert, or detect overlaps.
6 practice problems
An external resource we recommend. AlgoExpert is not affiliated with us and we earn nothing from this link.
Take it into the interview
Pair the patterns with the coding and system-design questions for your role, rehearse the behavioral round with worked STAR answers, and when the offer comes, check it against the salary comparison tool.