Number of Islands
Scan the grid cell by cell. When you find unvisited land, increment the island count and run DFS or BFS to mark every connected land cell as visited.
Count how many islands of connected land exist in a grid of '1' and '0' values.
Tagged with graph
Scan the grid cell by cell. When you find unvisited land, increment the island count and run DFS or BFS to mark every connected land cell as visited.
Count how many islands of connected land exist in a grid of '1' and '0' values.