algorithm · Level 2 · 25 min
Given a 2D grid grid of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and formed by connecting adjacent lands horizontally or vertically.
grid (2D array of '1' and '0').- `1 <= m, n <= 300` - `grid[i][j]` is '1' or '0'.
Return the island count (integer).