Loading problem…
Given an m x n 2D grid of "1" (land) and "0" (water), return the number of islands.
An island is formed by connecting adjacent lands horizontally or vertically.
Implement:
function numIslands(grid) {}numIslands([
['1', '1', '0'],
['1', '0', '0'],
['0', '0', '1'],
]); // 2
numIslands([
['0', '0'],
['0', '0'],
]); // 0