THN Interview Prep

Graphs

Graph problems are about modeling relationships first, then choosing the traversal or relaxation rule. Say what the nodes are, what the edges mean, whether the graph is directed/weighted, and what visited state prevents repeated work.

Mental Model

  • BFS: shortest path by number of edges or level-order expansion.
  • DFS: connected components, reachability, cycle checks, and backtracking over paths.
  • Topological sort: prerequisites and directed acyclic dependency order.
  • Union-Find: dynamic connectivity and component merging.
  • Dijkstra / MST: weighted routing or minimum connection cost.

Diagram

Loading diagram…

Problem List

Start with 200. Number of Islands, 133. Clone Graph, 207. Course Schedule, 261. Graph Valid Tree, and 743. Network Delay Time.

Mark this page when you finish learning it.

Last updated on

Spotted something unclear or wrong on this page?

On this page