Skip to main content
CodeOath
← All posts

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 likePatternChapter
Sorted input, hunting a pair that hits a targetTwo pointers, opposite endsTwo Pointers & Sliding Window
"The longest/shortest run such that..."Sliding window, variable sizeTwo Pointers & Sliding Window
"A window of a fixed size k"Sliding window, fixed sizeTwo Pointers & Sliding Window
Same pair-hunting question, but the input isn't sortedHashingHashing Patterns
"Bucket these by some computed key"Hashing, frequency mapHashing Patterns
Checking that opens and closes line upStackStacks & Monotonic Stack
"Next bigger/smaller," "how long until it improves"Monotonic stackStacks & Monotonic Stack
"Every possible combination that satisfies a constraint"BacktrackingRecursion & Backtracking
"Every path from the root down to a leaf"Tree DFSTrees
"Level by level" / "shallowest match"BFS, level orderTrees, Graphs: BFS & DFS
Sorted input — locate a value, or where it would insertBinary searchBinary Search
"Minimize the worst case" over a range of candidatesBinary search on the answerBinary Search
"Fewest hops between two things," unweightedBFSGraphs: BFS & DFS
"How many separate clusters/groups exist"BFS/DFS, connected componentsGraphs: BFS & DFS
"Order these given dependencies" / "is this even schedulable"Topological sortGraphs: Topological Sort & Union-Find
"Are these connected," with links arriving one at a timeUnion-findGraphs: Topological Sort & Union-Find
"Count the ways" / "cheapest way to reach..." with repeated smaller casesDynamic programmingDynamic Programming Part 1 and 2
Comparing two sequences for how much they overlap, in order2D DP, LCS familyDynamic Programming Part 2
Items with a cost and a value, under one fixed budgetKnapsack DPDynamic Programming Part 2
Optimizing step by step, and each local pick can be proven safeGreedyGreedy Algorithms
"Top K" / "Kth largest or smallest"HeapHeaps & Priority Queues
Merging several sorted sources, or a running medianHeapHeaps & Priority Queues
Small, known range of integer values, and n log n isn't fast enoughCounting/radix sortSorting & 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.