DFS
Depth-first search on a 2D grid treats each cell as a node, with edges to its 4 neighbors (up, down, left, right). Starting from any unvisited cell, DFS explores as far as possible before backtracking.
Connected Components
A connected component in a grid is a maximal set of cells that are all reachable from each other via adjacent moves.
200. Number of Islands
419. Battleships in a Board
694. Number of Distinct Islands
733. Flood Fill
1034. Coloring A Border
463. Island Perimeter
695. Max Area of Island
3619. Count Islands With Total Value Divisible by K
Medium1 solutionanalysis1 playground
Solutions: