Print it. Stick it up. Read it in the ten minutes before a call.
← Full study site| “contiguous subarray”, “substring”, “window of size k” | Sliding Window |
| “sorted” + “pair / triplet / sum to target” | Two Pointers |
| “cycle”, “middle of the list”, “repeats forever” | Fast & Slow |
| “intervals”, “meetings”, “start and end times” | Merge Intervals |
| “n numbers in 1..n”, “missing”, “duplicate” | Cyclic Sort |
| “reverse the list”, “in place”, “O(1) space” | List Reversal |
| “level by level”, “fewest steps”, “nearest” | BFS |
| “all paths”, “connected region”, “does a path exist” | DFS |
| “top K”, “K most frequent”, “median of a stream” | Heaps |
| “all subsets”, “all permutations”, “place N things” | Backtracking |
| “rotated”, “first index where…”, “minimise the max” | Binary Search |
| “how many ways”, “min cost”, “longest subsequence” | DP |
| “sums to exactly k”, “values may be negative” | Prefix Sum |
| “next greater”, “span”, “histogram” | Monotonic Stack |
| “prerequisites”, “build order”, “can all finish” | Topological Sort |
| “connected components”, “edges arrive one at a time” | Union-Find |
| n ≤ 12 | O(n!) | permutations |
| n ≤ 20 | O(2ⁿ) | subsets, bitmask |
| n ≤ 100 | O(n⁴) | four loops |
| n ≤ 500 | O(n³) | Floyd-Warshall |
| n ≤ 5,000 | O(n²) | DP over pairs |
| n ≤ 10⁵ | O(n log n) | sort, heap, binary search |
| n ≤ 10⁶ | O(n) | one pass |
| n > 10⁸ | O(log n) | search the answer |
Budget 10⁷ operations per second in Python, not 10⁸.
| “O(1) extra space” | two pointers, in-place, Floyd |
| “do not modify the input” | cycle detection, binary search |
| “must be O(log n)” | binary search, an instruction |
| “the array is sorted” | never mentioned by accident |
| “values may be negative” | kills the sliding window |
| “queries arrive one at a time” | Union-Find, heap |
| n huge, k small | size-k heap, O(n log k) |
| “lowercase letters only” | 26-slot array, O(1) space |
lst.append, lst.pop(), lst[i] | O(1) |
lst.pop(0), lst.insert(0, x) | O(n) |
x in lst versus x in set | O(n) / O(1) |
lst[i:j] — it copies | O(j−i) |
s += ch in a loop | O(n²) |
"".join(parts) | O(n) |
deque.popleft, appendleft | O(1) |
heappush, heappop / heapify | O(log n) / O(n) |
bisect_left / insort | O(log n) / O(n) |
sorted(), stable, Timsort | O(n log n) |
No max-heap: push -value. No TreeMap: say so.
| 3 min | Clarify, then restate the problem and get a yes. |
| 2 min | Work their example by hand. Invent one edge case. |
| 2 min | State the brute force and its cost. Do not code it. |
| 6 min | Name the waste, name the pattern, cost it, ask before coding. |
| 18 min | Guard clauses first. Real names. Narrate decisions, not syntax. |
| 6 min | Dry-run a trace table. Diagnose out loud before fixing. |
| 3 min | Time, space, what n means, worst vs average. One follow-up. |
| Array | empty, one, two, all equal, sorted, reversed, all negative, zero |
| String | empty, one char, all same, palindrome, case, spaces |
| Linked list | None, one node, two, target at head, at tail, a cycle |
| Tree | None, one node, left-only chain, perfect, duplicates |
| Graph | no edges, self-loop, cycle, disconnected, duplicate edges |
| Grid | empty, one cell, one row, all blocked, all open |
| Intervals | empty, touching ends, one nested inside another, identical |
| k / target | k = 0, k = 1, k = n, k > n, target above the total |
nums[i-1] at i = 0?[left, right] is right - left + 1.left = mid loops forever. Use mid + 1.[[0]*n]*m aliases one row. Use a comprehension.is, values with ==.Companion to the 16 patterns and 6 guides, and the 61-problem flashcard deck.