Bookmark this. Night-before-interview revision: read the table, re-solve two judge problems, sleep.
The table
PATTERN TRIGGER SIGNAL TIME CORE MOVE ────────────────────────────────────────────────────────────────────────────── Two Pointers sorted + pairs / in-place edit O(n) converge or read/write Sliding Window longest/shortest subSTRING/ARRAY O(n) grow right, shrink left HashMap seen-before? / count / frequency O(n) trade space for lookups Fast & Slow linked list cycle / middle O(n) 1x and 2x speed Merge Intervals [start,end] pairs, overlaps O(n log n) sort by start, sweep Binary Search sorted / "min X such that" O(log n) halve the space Stack brackets / undo / next-greater O(n) LIFO + monotonic BFS shortest steps / level order O(V+E) queue + level size DFS/Backtracking all combinations / islands exp / O(mn) choose-explore-unchoose Top-K (Heap) K largest / most frequent O(n log k) size-K heap bouncer Prefix Sum repeated range sums O(n)+O(1) cumulative array Kadane's max subarray sum O(n) extend or restart LL Reversal reverse list in place O(n) prev/cur/next dance DP (1D) count ways / min cost / max value O(n·k) state + recurrence Greedy schedule max / provably-safe local O(n log n) sort + one sweep
The judge circuit (do these cold)
One problem per pattern, all on our judge with hidden tests: Two Sum · Longest Substring · Valid Parentheses · Binary Search · Reverse Linked List · Max Subarray · Climbing Stairs · Coin Change · Trapping Rain Water
The meta-rules
- Always state the brute force first — it's points AND a safety net.
- Patterns chain: K-most-frequent = hashmap + heap; palindrome list = fast/slow + reversal; subarray-sum-K = prefix + hashmap.
- Constraints hint the target: n ≤ 10⁵ wants O(n log n) or better; n ≤ 20 whispers backtracking/bitmask.
- Say complexity unprompted, and name the trade-off ("O(n) space for O(1) lookups").
Pair with the first-interview walkthrough and AI interview prep if you're targeting ML roles. Go get the offer. 🚀