PATHLIGHT
LESSON 07 OF 08Number of Islands
0% learnt
NUMBER OF ISLANDS · GRID AS A GRAPH

The scan reaches unvisited land at (0,0). What should happen?

This cell cannot belong to an island counted earlier, so it starts exactly one new connected component.

RULE TO APPLYOuter scan finds a new island; one flood fill marks that whole island.
LIVE ALGORITHM STATEIncrement once, then flood-fill from (0,0).
ISLAND COUNT
01