43. Number of Islands
MediumGraphs
grid is a 2D array of "1" (land) and "0" (water). Count the islands: groups of land connected horizontally or vertically.
Example 1
Input: grid = [["1","1","0"],["1","0","0"],["0","0","1"]] Output: 2
Constraints
1 ≤ rows, columns ≤ 300