Interviewers don't hand out thousands of unrelated puzzles. They ask variations of about twenty ideas. Learn what each idea is for, how it moves, the clues that give it away, and a hook that makes it stick. Then every new problem turns into a question you already know how to answer: "which of my 24 tools fits?"
Every pattern page has the same 10 sections. Press Play on each visualizer, or step with ← →, and watch the pointers, windows and stacks move.
Every page has a Python template. Retype it from memory until you can write it without looking. Then solve the practice problems on LeetCode, which runs the full test suite for you.
Before coding any problem, name the pattern and say why. Use the pattern finder and the "how to spot it" section on each page.
New to coding interviews? Follow these steps top to bottom. Each step is one pattern page: read sections 1–6, run the visualizers, then solve its Start here problems before the rest. Hover or tap a dotted word on any page to see what it means.
Big-O, the core data structures, recursion, the Python toolkit and how to read a LeetCode problem. Skip what you already know.
Read and write arrays and strings carefully: one pass, a lookup table, clean output.
First problems: 13. Roman to Integer, 58. Length of Last Word, 14. Longest Common Prefix
Remember what you've seen in a dict or set: the fix for most slow nested loops.
First problems: 1. Two Sum, 242. Valid Anagram, 217. Contains Duplicate
Last in, first out: brackets, undo, evaluating expressions.
First problems: 20. Valid Parentheses, 682. Baseball Game, 155. Min Stack
Two indices instead of two nested loops.
First problems: 344. Reverse String, 125. Valid Palindrome, 167. Two Sum II – Input Array Is Sorted
A moving range over an array or string.
First problems: 121. Best Time to Buy and Sell Stock, 643. Maximum Average Subarray I, 3. Longest Substring Without Repeating Characters
Running totals, so any range sum is one subtraction.
First problems: 303. Range Sum Query – Immutable, 560. Subarray Sum Equals K, 238. Product of Array Except Self
Halve the search space every step.
First problems: 704. Binary Search, 35. Search Insert Position, 278. First Bad Version
Two speeds on a linked list: middles and cycles.
First problems: 876. Middle of the Linked List, 141. Linked List Cycle, 202. Happy Number
Rewire next pointers without losing the list.
First problems: 206. Reverse Linked List (iterative + recursive), 21. Merge Two Sorted Lists, 92. Reverse Linked List II
Heaps: the k biggest, smallest or most frequent.
First problems: 1046. Last Stone Weight, 703. Kth Largest Element in a Stream, 215. Kth Largest Element in an Array
Sort by start, then merge or compare neighbours.
First problems: 252. Meeting Rooms, 56. Merge Intervals, 57. Insert Interval
A stack kept in order: next greater or smaller element.
First problems: 496. Next Greater Element I, 739. Daily Temperatures, 503. Next Greater Element II
Trees, graphs, backtracking and DP are all recursive. Step through the call stack once more before starting them.
Visit every node of a tree; most answers are one recursive function.
First problems: 104. Maximum Depth of Binary Tree, 226. Invert Binary Tree, 94. Binary Tree Inorder Traversal
Go deep first: paths, islands, components, cycles.
First problems: 1971. Find if Path Exists in Graph, 547. Number of Provinces, 133. Clone Graph
Level by level with a queue: shortest paths when every step costs 1.
First problems: 637. Average of Levels in Binary Tree, 111. Minimum Depth of Binary Tree, 994. Rotting Oranges
A grid is a graph: neighbours are up, down, left and right.
First problems: 733. Flood Fill, 200. Number of Islands, 695. Max Area of Island
Choose, explore, un-choose: subsets, permutations, combinations.
First problems: 78. Subsets, 46. Permutations, 39. Combination Sum
Backtracking with a memory: reuse answers to smaller problems.
First problems: 509. Fibonacci Number, 70. Climbing Stairs, 198. House Robber (1-D linear)
Take the locally best choice when you can prove it's safe.
First problems: 122. Best Time to Buy and Sell Stock II, 55. Jump Game, 1833. Maximum Ice Cream Bars
Build your own structures: prefix trees and O(1) designs.
First problems: 208. Implement Trie (Prefix Tree), 1472. Design Browser History, 146. LRU Cache
Weighted graphs: cheapest routes and connections.
First problems: 743. Network Delay Time, 1584. Min Cost to Connect All Points, 1631. Path With Minimum Effort
Number and bit tricks.
First problems: 1492. The kth Factor of n, 7. Reverse Integer, 50. Pow(x, n)
Groups that only ever merge.
First problems: 684. Redundant Connection, 990. Satisfiability of Equality Equations, 1319. Number of Operations to Make Network Connected
Range queries with updates.
First problems: 307. Range Sum Query - Mutable, 3479. Fruits Into Baskets III, 315. Count of Smaller Numbers After Self
The italic line on each card is its memory hook. Learn the hooks first and the details will attach to them.
Group the 24 into six "rooms". When you read a problem, first pick the room from the data structure, then the pattern inside it.
Answer a few questions about the problem in front of you. Each answer narrows things down until one or two patterns are left, the same way an expert thinks it through.
| If the problem says… | Think |
|---|
left, window_sum, seen).n ≤ 10 → backtracking O(n!) or O(2ⁿ) is fine · n ≤ 20 → O(2ⁿ) · n ≤ 500 → O(n³) · n ≤ 5,000 → O(n²) · n ≤ 10⁶ → O(n log n) or O(n). The constraint on n often tells you the pattern.Dynamic Programming, Greedy + mixed review using the cheat sheet
Backtracking + memory = DP; one safe choice = Greedy.
Math & Bits, Union-Find, Segment & Fenwick Tree
The specialist tools that turn hard problems into short ones.
Preparing for a specific interview over a longer period? The 6-month Google plan, Meta plan, Amazon plan, Microsoft plan, Apple plan, Nvidia plan, Cisco plan and Netflix plan spread the same patterns over 26 weeks with each company's real interview problems.