Number of Islands
Description
Given a 2D grid of '1' (land) and '0' (water), count the number of
islands. An island is a maximal group of '1' cells connected
horizontally or vertically (NOT diagonally).
Example:
grid = [["1","1","0"],
["1","0","0"],
["0","0","1"]]
-> 2 islands (the L-shape in the top-left, and the lone '1' at bottom-right) Constraints
- Grid dimensions up to 300x300 - Cells are strings '0' or '1' (not ints) - Diagonal connections don't count - Empty grid returns 0
solution.py
output
Run the cases to see results here.