Step 1: Start scanning from top-left; find first land at (0,0), start BFS to mark this island
[1,1,0,0,0]
[1,1,0,0,1]
[0,0,0,1,1]
[0,0,0,0,0]
[1,0,1,0,1]
Visited: (0,0)
Why: We found the first island's starting point to explore all connected land
Step 2: BFS visits neighbors (0,1), (1,0), (1,1) marking them visited
[V,V,0,0,0]
[V,V,0,0,1]
[0,0,0,1,1]
[0,0,0,0,0]
[1,0,1,0,1]
Visited: (0,0),(0,1),(1,0),(1,1)
Why: Marking all connected land cells to count as one island
Step 3: Continue scanning grid; find next unvisited land at (1,4), start BFS for second island
[V,V,0,0,0]
[V,V,0,0,V]
[0,0,0,1,1]
[0,0,0,0,0]
[1,0,1,0,1]
Visited: previous + (1,4)
Why: Found a new island separate from the first
Step 4: BFS visits neighbors (2,4), (2,3) marking them visited
[V,V,0,0,0]
[V,V,0,0,V]
[0,0,0,V,V]
[0,0,0,0,0]
[1,0,1,0,1]
Visited: previous + (2,3),(2,4)
Why: Marking all connected land cells of second island
Step 5: Continue scanning; find land at (4,0), mark visited as third island
[V,V,0,0,0]
[V,V,0,0,V]
[0,0,0,V,V]
[0,0,0,0,0]
[V,0,1,0,1]
Visited: previous + (4,0)
Why: New isolated land cell is a separate island
Step 6: Find land at (4,2), mark visited as fourth island
[V,V,0,0,0]
[V,V,0,0,V]
[0,0,0,V,V]
[0,0,0,0,0]
[V,0,V,0,1]
Visited: previous + (4,2)
Why: Another isolated land cell forms a new island
Step 7: Find land at (4,4), mark visited as fifth island
[V,V,0,0,0]
[V,V,0,0,V]
[0,0,0,V,V]
[0,0,0,0,0]
[V,0,V,0,V]
Visited: previous + (4,4)
Why: Last isolated land cell is a separate island
Result: Visited all islands.
Final count: 5 islands