Grinding 500 LeetCode problems is the slow way to prep. The fast way is pattern recognition — because most interview questions are a remix of ~15 underlying patterns. Once you can name the pattern in the first 30 seconds, you stop solving from scratch and start adapting a template you already know.
Here are the 15 that, in my experience, cover the vast majority of what actually shows up. For each: the signal that tells you to reach for it, and a representative problem.
The 15 patterns
1. Sliding Window — Signal: a contiguous subarray/substring, "longest/shortest/at most K." Ex: Longest Substring Without Repeating Characters.
2. Two Pointers — Signal: a sorted array, or pairs/triplets that sum to a target. Ex: 3Sum, Container With Most Water.
3. Fast & Slow Pointers — Signal: cycles, or finding the middle of a linked list in one pass. Ex: Linked List Cycle, Happy Number.
4. Merge Intervals — Signal: overlapping intervals, scheduling, "merge/insert." Ex: Merge Intervals, Meeting Rooms II.
5. Cyclic Sort — Signal: an array of numbers in a known range [1..n], find missing/duplicate. Ex: Find All Numbers Disappeared in an Array.
6. In-place Linked List Reversal — Signal: reverse a list (or a sublist) with O(1) space. Ex: Reverse Linked List II.
7. BFS (Tree/Graph) — Signal: shortest path on an unweighted graph, or level-order traversal. Ex: Binary Tree Level Order Traversal, Word Ladder.
8. DFS (Tree/Graph) — Signal: explore all paths, connected components, backtracking-ish traversal. Ex: Number of Islands, Path Sum.
9. Two Heaps — Signal: you need the median of a stream, or to balance "smaller half / larger half." Ex: Find Median from Data Stream.
10. Subsets / Backtracking — Signal: generate all combinations/permutations/subsets. Ex: Subsets, Permutations, Combination Sum.
11. Modified Binary Search — Signal: a sorted (or rotated-sorted) input, or "minimize the maximum." Ex: Search in Rotated Sorted Array, Koko Eating Bananas.
12. Top K Elements — Signal: "K largest/smallest/most frequent." Reach for a heap. Ex: Kth Largest Element, Top K Frequent Elements.
13. K-way Merge — Signal: merge K sorted lists/arrays. Ex: Merge k Sorted Lists.
14. Dynamic Programming — Signal: "count the ways," "min/max cost," or overlapping subproblems. Start with the recurrence. Ex: Coin Change, Longest Common Subsequence, House Robber.
15. Topological Sort — Signal: ordering with dependencies, a DAG, "can you finish?" Ex: Course Schedule.
How to actually study these (so they stick)
- Learn the signal, not just the solution. For each pattern, write down the words in the prompt that trigger it. That recognition is the whole game.
- Do 3–5 problems per pattern, not 50 random ones. Depth on one pattern beats breadth across many.
- Re-derive the template from memory. If you can rebuild the sliding-window skeleton on a blank page, you own it. If you're copying, you don't yet.
- Mix patterns once each is solid. Real interviews don't tell you the pattern — practice cold recognition.
The goal isn't to memorize 500 solutions. It's to walk in able to say, "this is a top-K problem," and reach for the heap before you've even finished reading.
I wrote the full breakdown — with template code for every pattern, Big-O, and the exact signal-words that map a prompt to a pattern — here: The 15 LeetCode Patterns That Cover 90% of Coding Interviews.
What pattern trips you up the most? For me it was two-heaps until it suddenly clicked. Curious what yours is.
Disclosure: I work on CoPilot Interview, an interview-prep tool — but this pattern list stands entirely on its own, and the linked guide is free to read.
Top comments (0)