Skip to main content

Graph Mastery 14-Day

Spot DFS vs BFS vs union-find vs Dijkstra at the problem statement, narrate the choice, and ship the solution without rebuilding the templates from scratch.

By Alex Chen, Founder, InterviewChamp.AI · 14 problems · ~22h · difficulty: mixed · Last verified

  1. Day 1Number of Islands(graphs)

    Grid DFS with visited marking. The 'count connected regions' template — every grid graph problem starts here.

  2. Same shape as islands, different surface. Practice on the adjacency-list version — the data structure swap is the whole exercise.

  3. Day 3Clone Graph(graphs)

    Hash map old-to-new doubles as your visited set. The pattern: visited acts double-duty as the clone-lookup. Name it out loud.

  4. Reverse the question: instead of 'can water reach the ocean from this cell?', BFS FROM each ocean. The inversion is the interview signal.

  5. Day 5Graph Valid Tree(graphs)

    A tree is a connected graph with exactly n-1 edges and no cycles. Two checks, one pass. Or use union-find — both answers buy you points.

  6. Union-find gateway. Process edges; the first one that unions two already-connected nodes is your answer. Memorize the union-find template now.

  7. Day 7Course Schedule(graphs)

    Topological sort via DFS-cycle-detection. The 'three colors' framing (unvisited, in-stack, done) is the answer interviewers want to hear.

  8. Day 8Course Schedule II(graphs)

    Same engine, return the order. Kahn's BFS variant is cleaner here — practice both and pick one to defend.

  9. Day 9Word Ladder(graphs)

    BFS where 'neighbors' = one-letter-different words. The wildcard-bucket preprocessing trick is the unlock — don't compare every pair.

  10. Day 10Accounts Merge(graphs)

    Union-find on emails. The trick: each email points to its account. Merge accounts whose emails overlap. The data modeling IS the problem.

  11. Day 11Evaluate Division(graphs)

    Weighted graph + DFS. Each edge carries a ratio. Multiply along the path. First problem where edges have data beyond 'connected'.

  12. Day 12Network Delay Time(graphs)

    Dijkstra template. Priority queue, distance map, relax edges. Drill the boilerplate — Cheapest-flights is the same engine.

  13. Modified Dijkstra (or Bellman-Ford) with a stop counter in state. The classic 'state = (node, steps)' DP-graph hybrid.

  14. Day 14Alien Dictionary(graphs)

    Capstone. Build the graph from word pairs, then topological sort. The graph construction is the interview — the toposort is rote.

Ready to drill these live?

Get the AI copilot in your ear during real interviews. Real-time transcription. Streaming answers. Post-call scorecard.

Download the desktop app →