If you've been grinding LeetCode without a plan, you already know the problem: there are thousands of questions, but only a handful of underlying patterns. Once you recognize the pattern, most "new" problems stop feeling new.
Here are the 7 patterns that keep showing up across interviews at companies of every size — and how to recognize them fast.
- Two Pointers
Signal: Sorted array, or you're comparing pairs/windows from both ends.
Classic problems: Pair sum in sorted array, container with most water, remove duplicates in place.
Why it works: You collapse an O(n²) brute-force scan into O(n) by moving two indices toward each other based on a comparison.
- Sliding Window
Signal: "Longest/shortest substring/subarray that satisfies X."
Classic problems: Longest substring without repeating characters, max sum subarray of size k, minimum window substring.
Why it works: Instead of recomputing a window from scratch every time, you slide it — adding one element, removing one — keeping the computation incremental.
- Fast & Slow Pointers (Tortoise and Hare)
Signal: Anything involving cycles or finding a "middle" without extra space.
Classic problems: Detect a cycle in a linked list, find the middle node, find duplicate number in an array.
Why it works: Two pointers moving at different speeds will eventually meet if there's a cycle — no hash set required.
- Merge Intervals
Signal: You're given a list of ranges and need to combine, insert, or check for overlaps.
Classic problems: Merge overlapping intervals, insert interval, meeting rooms.
Why it works: Sort by start time first — almost every interval problem becomes trivial once sorted.
- Top-K Elements (Heap)
Signal: "Find the k largest/smallest/most frequent..."
Classic problems: Kth largest element, top k frequent words, k closest points to origin.
Why it works: A heap keeps the k best candidates without sorting the entire dataset — O(n log k) instead of O(n log n).
- Backtracking
Signal: "Generate all possible..." or "find all valid combinations."
Classic problems: Permutations, subsets, N-Queens, Sudoku solver.
Why it works: You explore a decision tree, and prune branches early the moment they can't lead to a valid answer — that pruning is what keeps it from being pure brute force.
- Dynamic Programming (the one everyone fears)
Signal: "Maximum/minimum/number of ways to..." with overlapping subproblems.
Classic problems: Climbing stairs, coin change, longest common subsequence, knapsack.
Why it works: You cache the answer to subproblems so you never recompute the same thing twice. The trick isn't the code — it's correctly defining the state and the transition.
How to actually practice this (not just read about it)
Recognizing a pattern in an article is easy. Recognizing it cold, in a 35-minute interview, under pressure, is a different skill entirely. A few things that actually move the needle:
Drill by pattern, not by difficulty. Doing 10 sliding-window problems back to back builds pattern recognition far faster than doing 10 random "medium" problems.
Time yourself. If you can't identify the pattern in the first 3 minutes, you need more reps on that pattern specifically, not a harder problem.
Explain out loud as you solve. Interviewers are grading your reasoning, not just your final code.
If you want a structured, topic-wise way to drill these (plus language-specific interview Q&A, system design, and mock interviews), I put together InterviewPitch — it's free and organized so you can practice pattern by pattern instead of jumping between random blog posts.
What pattern do you find hardest to spot under pressure? Curious what trips people up most — drop it in the comments.
Top comments (0)