200. Number of Islands
Practice Number of Islands for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
The grid is a map where "1" is land and "0" is water. An island is a group of land cells connected up, down, left or right (not diagonally). Everything outside the grid is water. Count the islands.
Example
grid = [["1","1","0","0","0"],
["1","1","0","0","0"],
["0","0","1","0","0"],
["0","0","0","1","1"]] -> 3
Constraints
- 1 <= m, n <= 300 (m rows, n columns)
- grid[i][j] is
"0"or"1"