MediumGraph· 56% acceptance
#932

Number of Islands 42

Medium

Count islands of `'1'` cells in a 2D grid (`'0'` is water). Variant **#42**.

Example 1

Input: grid = 5x5 matrix

Output: 8

Constraints

  • m == grid.length
  • n == grid[i].length

Acceptance: 56% · Topics: graph, dfs, matrix

numIslands

← All practice problems