Home
Day 5 · Week 1

Fundamentals Consolidation

Level 1 · Review  ·  2 hrs: ~30 min synthesis · ~90 min timed drills

🧠 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:

QuestionIf 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:

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 problemTool
"Fewest steps / minimum moves," unweightedBFS (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.

Week 1 Exit Check

You're ready for Week 2 (Shortest Path) if you can, without notes:

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.