Problems > Count the Lakes > Editorial

Count the Lakes — Solution & Editorial

Back to the Problem

Flood fill from every unvisited water cell using BFS/DFS over the four side-neighbours.

Complexity: O(NM)