Data Structures & Algorithms105 min total · 16 parts
DSA Patterns for Coding Interviews: The Techniques Behind Almost Every Problem
Part 16 of 16 · ~3 min
A Decision Guide: Matching Problem Signals to Patterns
The hard part of an unfamiliar problem is almost never writing the pattern once you've named it — a sliding window, once recognized, is usually easy to code. The actual skill is spotting which pattern a problem wants underneath whatever costume it's wearing — a course planner here, a delivery fleet somewhere else, a stock ticker in the next one. Here's the lookup worth having memorized:
| What the problem sounds like | Pattern | Chapter |
|---|---|---|
| Sorted input, hunting a pair that hits a target | Two pointers, opposite ends | Two Pointers & Sliding Window |
| "The longest/shortest run such that..." | Sliding window, variable size | Two Pointers & Sliding Window |
| "A window of a fixed size k" | Sliding window, fixed size | Two Pointers & Sliding Window |
| Same pair-hunting question, but the input isn't sorted | Hashing | Hashing Patterns |
| "Bucket these by some computed key" | Hashing, frequency map | Hashing Patterns |
| Checking that opens and closes line up | Stack | Stacks & Monotonic Stack |
| "Next bigger/smaller," "how long until it improves" | Monotonic stack | Stacks & Monotonic Stack |
| "Every possible combination that satisfies a constraint" | Backtracking | Recursion & Backtracking |
| "Every path from the root down to a leaf" | Tree DFS | Trees |
| "Level by level" / "shallowest match" | BFS, level order | Trees, Graphs: BFS & DFS |
| Sorted input — locate a value, or where it would insert | Binary search | Binary Search |
| "Minimize the worst case" over a range of candidates | Binary search on the answer | Binary Search |
| "Fewest hops between two things," unweighted | BFS | Graphs: BFS & DFS |
| "How many separate clusters/groups exist" | BFS/DFS, connected components | Graphs: BFS & DFS |
| "Order these given dependencies" / "is this even schedulable" | Topological sort | Graphs: Topological Sort & Union-Find |
| "Are these connected," with links arriving one at a time | Union-find | Graphs: Topological Sort & Union-Find |
| "Count the ways" / "cheapest way to reach..." with repeated smaller cases | Dynamic programming | Dynamic Programming Part 1 and 2 |
| Comparing two sequences for how much they overlap, in order | 2D DP, LCS family | Dynamic Programming Part 2 |
| Items with a cost and a value, under one fixed budget | Knapsack DP | Dynamic Programming Part 2 |
| Optimizing step by step, and each local pick can be proven safe | Greedy | Greedy Algorithms |
| "Top K" / "Kth largest or smallest" | Heap | Heaps & Priority Queues |
| Merging several sorted sources, or a running median | Heap | Heaps & Priority Queues |
| Small, known range of integer values, and n log n isn't fast enough | Counting/radix sort | Sorting & Searching Beyond the Basics |
A table doesn't substitute for having written the code. Recognizing a pattern on the page and reproducing it cold, under a clock, dressed in language you haven't seen before, are two different skills, and only repetition closes the gap. Every row above has real problems waiting in Code Lab — work enough of them that the recognition step starts happening before you've even finished reading the prompt.
Practice this
Continue learning
- Interview & Career PrepThe Non-Technical Half of the Interview: Behavioral Questions, the STAR Method, and What Recruiters Are Actually Scoring
- AI & LLM EngineeringAI & LLM Engineering Fundamentals: Prompting, RAG, Embeddings, and Function Calling
- TypeScriptTypeScript Fundamentals: Types, Interfaces, Generics, and Why It Catches Bugs Before Runtime