Every problem on the Codolio / Neetcode 150 / Striver A2Z / Blind 75 sheet falls into about 18 recurring patterns. Master the pattern -> recognise it in seconds -> apply the template.
Use the sidebar to jump to any pattern.
| # | Pattern | When you see… | Classic problems |
|---|---|---|---|
| 1 | Sliding Window | longest/shortest subarray with constraint | Max Sum Subarray of Size K, Longest Substring w/o Repeats |
| 2 | Two Pointers | sorted array -> find pair / reverse | Two Sum (Sorted), Valid Palindrome |
| 3 | Fast & Slow | linked list cycle / find middle | Linked List Cycle, Middle of LL |
| 4 | Merge Intervals | overlapping time-slots / ranges | Merge Intervals, Insert Interval |
| 5 | Cyclic Sort | numbers in [1..N] in O(1) space | Missing Number, Find Corrupt Pair |
| 6 | In-place Reversal | reverse linked list in chunks | Reverse LL, Reverse K-Group |
| 7 | BFS | shortest path / level-order | Level Order, Rotting Oranges |
| 8 | DFS | path exists / connectivity / topo | Number of Islands, Clone Graph |
| 9 | Binary Search | sorted array / monotone function | Search in Rotated Array, Koko Bananas |
| 10 | Topological Sort | task scheduling dependency | Course Schedule, Alien Dictionary |
| 11 | Backtracking | ”all” combinations / permutations | Subsets, N-Queens, Word Search |
| 12 | Dynamic Programming | overlapping subproblems | Coin Change, LCS, Edit Distance |
| 13 | Greedy | activity selection / interval scheduling | Jump Game, Gas Station |
| 14 | Bit Manipulation | XOR to find unique / set bits | Single Number, Counting Bits |
| 15 | Heap / Priority Queue | top-K / running median | Kth Largest, Median from Stream |
| 16 | Trie | prefix search / autocomplete | Implement Trie, Word Search II |
| 17 | Monotonic Stack | ”next greater element” | Daily Temperatures, Largest Rectangle |
| 18 | Prefix Sum | subarray sum queries | Subarray Sum Equals K, Range Sum |
Mnemonic: every pattern has a one-line trigger. Memorise the trigger, not the steps.
+-------------------+ +-------------------+ +-------------------+
| Read problem | ---> | Identify pattern | ---> | Apply template |
| text & examples | | from triggers | | & tweak |
+-------------------+ +-------------------+ +-------------------+
|
v
+-------------------+
| Verify with edge |
| cases + dry run |
+-------------------+
If you cannot name the pattern within 5 minutes of reading the problem: