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.
LC 286 Walls and Gates asks you to fill each empty room with its distance to the nearest gate. The key insight is to flip the direction: instead of BFS from every room, do multi-source BFS from all gates simultaneously and push distances outward in O(m*n) time.
LC 1020 Number of Enclaves asks you to count land cells that cannot reach the grid boundary. The trick is to flip the problem: flood-fill from the boundary inward, eliminating all reachable land, then count what remains.
LC 1905 Count Sub Islands asks how many islands in grid2 are subsets of islands in grid1. The critical trap is short-circuiting DFS on the first invalid cell — you must always complete the traversal to mark the whole island visited, while tracking validity separately.
Count islands with unique shapes by encoding each DFS traversal path as a string and storing shapes in a set. A classic interview problem testing DFS + hashing.
Count land islands fully surrounded by water (no border touch). Flood-fill border land first to eliminate open islands, then count remaining closed components.
Find the minimum number of 0s to flip to connect two islands. Use DFS to color the first island, then multi-source BFS to expand outward until hitting the second island.
Find the path from top-left to bottom-right that minimizes the maximum absolute difference between consecutive cells. Dijkstra treats effort as edge weight; binary search + BFS checks feasibility for each candidate effort.
BFS from the entrance to find the nearest border empty cell that is not the entrance. Classic BFS shortest-path on a grid with a carefully defined exit condition.
Minimum dice rolls to reach square n² from square 1. The hard part is converting square numbers to board coordinates in Boustrophedon (snake) order. BFS on the state space of squares gives the optimal answer.
Solve LeetCode 994 Rotting Oranges step by step using multi-source BFS with a queue. A FAANG interview favorite at Amazon, Google, and Microsoft that teaches level-order traversal, simultaneous infection spread, and grid traversal patterns.
Solve LeetCode 200 Number of Islands using BFS with a queue or DFS with a stack. The most asked grid interview question at Amazon, Google, Meta, and Microsoft, teaching connected components and flood fill.
Solve LeetCode 417 Pacific Atlantic Water Flow with reverse BFS from both ocean borders using a deque queue. A FAANG grid traversal classic asked at Amazon, Google, and Meta.
LeetCode 212 — find every dictionary word hidden in a board. The optimal solution builds a trie over the words and DFS-traverses the grid once, pruning entire branches the moment the path leaves the trie. A textbook FAANG hard problem.