Topic frequency tells you what to study. Patterns tell you how to solve it once
the question is in front of you. These are different skills, and the second one is what actually
wins interviews. A strong candidate doesn't recall the answer to a problem — they recognise its
shape in the first 60 seconds and reach for the matching template.
The good news: there are only about fifteen of these shapes. Master the recognition trigger for
each, and the overwhelming majority of interview questions become "oh, that's a sliding window with
a twist" instead of a blank-page panic. Here's the catalogue.
The recognition table
Read this column-by-column. When you see the signal on the left in a problem statement, the
pattern on the right is your first guess — right far more often than chance.
| If you see this signal | Reach for |
| Sorted array, find a pair/triplet summing to a target | Two pointers |
| Longest/shortest contiguous subarray or substring | Sliding window |
| Range-sum queries, "subarray with sum K" | Prefix sums |
| Cycle detection, find the middle, k-th from end (linked list) | Fast & slow pointers |
| Overlapping or back-to-back intervals to merge/schedule | Merge intervals |
| "Find the smallest/largest value such that…" on a monotonic answer | Binary search on answer |
| Top-K, k-th largest, streaming median | Heap / priority queue |
| All permutations / combinations / subsets / valid configurations | Backtracking |
| Grid/maze, connected components, shortest path in unweighted graph | BFS / DFS on graph |
| Dependencies, ordering, prerequisites | Topological sort |
| Next greater/smaller element, spans, histograms | Monotonic stack |
| "Min/max number of ways", overlapping subproblems & choices | Dynamic programming |
| Locally optimal choice obviously leads to global best | Greedy |
| Prefix/word lookups, autocomplete | Trie |
| Grouping elements, "are these connected", merging sets | Union-Find (DSU) |
The four you'll use most
Five patterns carry the bulk of array/string interviews. Get fluent in these before anything else.
Two pointers
Trigger: a sorted array and a relationship between two elements. The classic tell is
"find a pair/triplet that sums to X". Representative problems from the curated set: Two Sum II (sorted
input), 3Sum, Container With Most Water, removing duplicates from a sorted array.
Sliding window
Trigger: the word contiguous plus "longest", "shortest", or "at most K". You grow a
window from the right and shrink from the left to maintain a constraint. Representative: longest
substring without repeating characters, minimum window substring, max sum subarray of size K,
fruit-into-baskets.
Fast & slow pointers
Trigger: a linked list (or implicit cycle) where you need the middle, a loop, or the k-th node from
the end without knowing the length. Representative: linked list cycle detection, middle of a linked
list, happy number, palindrome linked list.
Dynamic programming
Trigger: overlapping subproblems and a sequence of choices where each
choice affects what's available next ("take it or skip it"). If brute-force recursion recomputes the
same state, that's your DP signal. Representative: climbing stairs, house robber, coin change,
longest common subsequence, 0/1 knapsack. DP is the pattern people fear most — but it's just
recursion plus a memo table, learned by repetition.
The study loop: pick one, solve eight, move on
Do not solve random problems. Patterns are learned by concentration, not variety. The loop
that works:
- Pick one pattern. Read its recognition trigger above until you can state it from memory.
- Solve one easy example with the solution open. You're learning the template, not testing yourself yet.
- Solve 6–8 more of the same pattern, increasing difficulty. By problem four you should spot the shape before reading the constraints.
- Write the trigger and template in one line in your own notes. "Sorted + pair sum → two pointers from both ends."
- Move on. Don't perfect a pattern — eight reps is enough to recognise it. Come back during revision.
Fifteen patterns at eight problems each is about 120 focused problems — a few weeks of honest work,
not months. That's the whole game.
Practise them in role-relevant order
Not every pattern is worth the same to every candidate. A frontend loop leans on two pointers,
sliding window, and hashing; a backend loop pulls graphs, topological sort, and heaps up front. So
sequence your fifteen patterns by the role you're targeting rather than alphabetically. That ordering
is exactly what SUITS does — it reorders the curated Apna College, Love Babbar 450,
and Striver A2Z problems so the patterns your target role tests most appear first.
For which patterns matter most by role, see the
DSA roadmap by role. To fit this pattern
work into a deadline, drop it into the
90-day placement plan.