Course outline · 0% complete

0/30 lessons0%

Course overview →

The pattern-recognition checklist

lesson 11-1 · ~12 min · 29/30

The pattern-recognition checklist

You now own ten patterns. Interview problems rarely announce which one they want, but they leak it through trigger phrases. This table is the course in one screen. Read the cue, name the pattern, recall the lesson:

The problem says...Reach forBuilt in
sorted input, or O(log n) requiredbinary search2-2
smallest/largest X that passes a monotonic testbinary search on the answer2-3
pairs/order in an array, no better idea yetsort-then-solve3-3
pair in sorted data, palindrome, converging endstwo pointers4-1
best contiguous run/substring/subarraysliding window4-2
repeated range totals, count subarrays summing to kprefix sums4-3
all subsets / permutations / boardsbacktracking6-1, 6-2
fewest steps, all steps equal costBFS7-2
explore/count regions, connectivityDFS7-1, 7-2
fastest route with weights ≥ 0Dijkstra10-2
prerequisites, must-come-beforetopological sort10-3
max/min/count over choices that interactDP9-1 → 10-1
"seen before?", counting, complementshash set/dict1-1

Greedy (unit 8) is the special case: propose it, hunt a counterexample, and only trust it with an exchange argument.

Quiz

"Given a maze, find the minimum number of moves from the entrance to the exit." Which pattern?

Quiz

"Find the smallest shipping capacity that delivers all packages within d days." Which pattern?

Code exercise · python

Capstone exercise: merge overlapping intervals, an interview staple that composes sort-then-solve (3-3) with neighbor merging. Sort, seed merged with the first interval, then either extend merged[-1] or append.

Problem

"Print every possible team of 3 people chosen from a list of 10." Which pattern from the checklist?