grid is a map of '1' (land) and '0' (water). Count the islands: groups of land cells joined horizontally or vertically.
Patterns: bfs, grid. Difficulty: medium.
Open in Dryrun