Number of Islands
You are given an m x n grid where each cell is either "1" (land) or "0" (water), as a 2-D array of single-character **strings**.
An **island** is a maximal group of "1" cells joined **4-directionally** (up, down, left, right — *not* diagonally), bounded by water or the edge of the grid. Assume the grid is surrounded by water on all sides.
Return the number of distinct islands.
Example cases
- one big islandin grid =11110110101100000000out 1All the land cells are connected horizontally or vertically into a single component.
- three islandsin grid =11000110000010000011out 3The top-left 2x2 block, the lone cell in the middle, and the bottom-right pair are three separate islands.
- single water cellin grid =0out 0
Constraints
- m == grid.length
- n == grid[i].length
- 1 <= m, n <= 300
- grid[i][j] is "0" or "1".
grid =
[["1","1","1","1","0"],["1","1","0","1","0"],["1","1","0","0","0"],["0","0","0","0","0"]]