Number of Islands

Problem

Count the number of islands in an m×n binary grid. An island is a group of 1s connected 4-directionally (up/down/left/right), surrounded by 0s (water).

Example

[[1,1,0],[0,1,0],[0,0,1]] -> 2

Constraints

  • 1 ≤ m, n ≤ 300
added …
LeaderboardSalaryAccount