157. Number of Islands

MediumGraph

Given an m x n 2D grid map of '1's (land) and '0's (water), return the number of islands. Grid is given as an array of strings.

Examples

Input: ["11110","11010","11000","00000"]

Output: 1

Explanation: Public test case for Number of Islands

Constraints

  • m == grid.length
  • n == grid[i].length
  • 1 <= m, n <= 300
Loading...

Run checks all cases above. Submit evaluates all test cases.