Master LeetCode 778 Swim in Rising Water by reducing a grid puzzle to a minimax shortest-path problem. Solve it three ways — Dijkstra with max-relax, binary search plus BFS, and Kruskal-style union-find — and learn when each approach wins. A FAANG hard interview classic at Google, Amazon, and Meta.
Process land additions one at a time and report the island count after each. Union-Find makes each query nearly O(1) amortized — the canonical online connectivity interview problem.
LeetCode 547 Number of Provinces is the canonical connected-components question. Learn the DFS, BFS, and Union Find solutions, master the adjacency-matrix walk, and rehearse the FAANG interview script.
A reachability check between two vertices in an undirected graph. Three optimal approaches: BFS, DFS, and Union Find — each with different trade-offs for follow-up questions about dynamic edges.
A graph is a valid tree iff it is connected and has no cycles, equivalently exactly n - 1 edges and one connected component. Solve with BFS, DFS, or Union Find — Union Find is shortest.
Count connected components by Union Find (decrement count on each successful union) or by BFS / DFS (increment count for each unvisited node). Both run in near-linear time.
Find the edge that closes a cycle when added to an n-node, n-edge graph. The first edge whose two endpoints share a Union Find root is the answer — a five-line solve.
LeetCode 886 Possible Bipartition reduces a real-world group split to a bipartite check. Master the BFS 2-coloring, DFS coloring, and Union Find variants that recruiters expect at FAANG.
LeetCode 399 Evaluate Division turns equations like A/B equals 2 into a weighted graph. Master the BFS, DFS, and Union Find solutions plus the FAANG-grade interview script.