Count the Lakes — Solution & Editorial
Flood fill from every unvisited water cell using BFS/DFS over the four side-neighbours.
Complexity: O(NM)
Flood fill from every unvisited water cell using BFS/DFS over the four side-neighbours.
Complexity: O(NM)