GraphsNumber of Islands
Progress
solution.py
⌘↵ run
Loading...

Number of Islands

medium
You've got this! Start small, think out loud.

Given a 2D grid of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.

Time:O(m*n)
Space:O(m*n)
dfsbfsgridgoogle-favorite
OUTPUT

Run your code to see output