You are given an image of a surface photographed by a satellite.The image is a bitmap where water is marked by \'.\' and land is marked by \'*\'. Adjacent group of
*
Create a undirected graph, where each island node connects to its neighboor island nodes.
While there are unvisited nodes:
Done.
Both (1) and (2) takes O(n) time.