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