CodeOath
← All posts
Data Structures & Algorithms43 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 hardest part of an unfamiliar interview problem is rarely the pattern's implementation — once you've identified it as a sliding window, you can probably write it correctly. The actual skill is recognizing which pattern a new problem is asking for, underneath whatever specific story it's dressed up in. This is the mapping worth having memorized cold:

Problem phrasing / constraintPatternChapter
"Find a pair that sums to X" (sorted input)Two pointers, opposite endsTwo Pointers & Sliding Window
"Longest/shortest substring or subarray satisfying..."Sliding window, variable sizeTwo Pointers & Sliding Window
"Subarray of exactly size k"Sliding window, fixed sizeTwo Pointers & Sliding Window
"Have you seen this value before" / "find duplicates"HashingHashing Patterns
"Group items by some computed key" (anagrams, etc.)Hashing, frequency mapHashing Patterns
"Valid parentheses" / matching opens and closesStackStacks & Monotonic Stack
"Next greater/smaller element" / "daily temperatures"Monotonic stackStacks & Monotonic Stack
"Generate all subsets/permutations/combinations"BacktrackingRecursion & Backtracking
"Every path from root to leaf"Tree DFSTrees
"Process level by level" / "minimum depth"BFS, level orderTrees, Graphs: BFS & DFS
Sorted array — find, or find the insertion point of, a valueBinary searchBinary Search
"Minimize the maximum" / "smallest value such that..." over a rangeBinary search on the answerBinary Search
"Shortest path" in an unweighted graphBFSGraphs: BFS & DFS
"How many separate groups/islands/components"BFS/DFS, connected componentsGraphs: BFS & DFS
"Order these given dependencies" / "can this be scheduled at all"Topological sortGraphs: Topological Sort & Union-Find
"Are these two things connected," with edges arriving incrementallyUnion-findGraphs: Topological Sort & Union-Find
"Count the ways to..." / "min or max cost to reach..." with overlapping smaller casesDynamic programmingDynamic Programming Part 1 and 2
Comparing two strings/sequences for similarity2D DP, LCS familyDynamic Programming Part 2
Items with weight/value under a capacity limitKnapsack DPDynamic Programming Part 2
"Maximize/minimize," and the locally best choice provably never backfiresGreedyGreedy Algorithms
"Top K" / "K largest or smallest" / "the Kth largest"HeapHeaps & Priority Queues
Merge K sorted lists, or a running median over a streamHeapHeaps & Priority Queues
Values are integers in a small, known range, and O(n log n) isn't fast enoughCounting/radix sortSorting & Searching Beyond the Basics

None of this table replaces actually writing the code. Reading a pattern and being able to reproduce it cold, under interview time pressure, on a problem phrased in an unfamiliar way, are genuinely different skills — and the gap between them closes only with repetition. Every pattern above has real, runnable problems tagged for it in the Code Lab; work through a handful from each pattern until the recognition step in this table starts happening automatically, before you ever read the problem's full description.