🧠 The Big Picture (synthesize Days 1–4)
By now you have one data structure (the graph) and one core traversal idea in two flavors
(BFS, DFS). Almost every fundamentals problem is: build the representation → traverse →
read off the answer. Today is about making that recognition automatic and fast.
Ask yourself these three questions on any new problem — they route you to the right tool:
| Question | If yes → |
| "Shortest number of steps / minimum moves?" | BFS (with level counting) |
| "Multiple starting points spreading out?" | Multi-source BFS |
| "Reachability, structure, or enumerate paths?" | DFS |
| "How many separate groups?" | Components = traversal in an outer loop |
| "Grid given?" | Treat cells as nodes, 4/8 directions as edges |
🔁 Recall Drill (do first, ~30 min)
Close your notes. On a blank file, reproduce from memory:
- The grid BFS template with level counting (Day 2).
- Recursive DFS flood fill (Day 3).
- The component-counting outer loop (Day 4).
Why from memory: interviews reward recall, not recognition. If you can't reproduce the template cold, re-read that day's file and try again tomorrow before Week 2.
🎭 Week 1 Variance Recap — fundamentals in disguise
Fast-recognition table pulling together Days 1–4. In an interview, map the phrasing to the tool in
seconds:
| Signal in the problem | Tool |
| "Fewest steps / minimum moves," unweighted | BFS (level-counting) |
| "Spreading from many origins" (fire, rot, gates) | Multi-source BFS |
| "All paths / enumerate possibilities" | DFS + backtracking |
| "Reachability, region shape/area" | DFS (post-order aggregate) |
| "How many groups / clusters" | Components (traversal in a loop) |
| "Are these two connected" | Component labels, or Union-Find (Wk2) |
| "Grid / maze / board" | Implicit graph — cells as nodes |
| "State richer than position" (keys, steps-left) | Encode into the node; BFS/DFS over states |
The one question that routes everything: "Do I need the shortest path (→ BFS) or just to explore/enumerate (→ DFS)?" — then add multi-source or state-augmentation as the twist demands.
🎯 New Problems (~60 min)
LC 733
Flood Fill
Warmup — the purest flood fill. Should take < 10 min now.
Easy
LC 417
Pacific Atlantic Water Flow
Multi-source traversal from BOTH oceans; intersect the reachable sets.
Med
LC 1020
Number of Enclaves
Border-flood trick again (cf. Surrounded Regions) — count what's left.
Med
⏱️ Timed Redo (~30 min)
Pick one problem from each of Days 2–4 and re-solve under 20 min each. Goal: fluency, not novelty. If any takes longer, that topic needs another pass.
- Day 2 pick: e.g. LC 994 Rotting Oranges
- Day 3 pick: e.g. LC 200 Number of Islands
- Day 4 pick: e.g. LC 323 Connected Components
✅ Week 1 Exit Check
You're ready for Week 2 (Shortest Path) if you can, without notes:
- Write BFS and DFS templates in < 5 min each.
- Explain why BFS gives shortest paths in unweighted graphs (the ring argument).
- Convert a grid problem to a graph traversal instantly.
- Count connected components correctly (restart = new component).
Next up: Week 2 adds weights. BFS's shortest-path guarantee breaks once edges have different costs — that's exactly the gap Bellman-Ford and Dijkstra fill.