arrow_back Back to Challenges

#200 Number of Islands

Medium Acceptance 0%
description

Problem Description

Given an `m x n` 2D binary grid `grid` which represents a map of `'1'`s (land) and `'0'`s (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.

checklist Constraints

m == grid.length
n == grid[i].length
1 <= m, n <= 300
grid[i][j] is '0' or '1'.

science Examples

Case #1

In: grid = [["1","1","0","0","0"],["1","1","0","0","0"],["0","0","1","0","0"],["0","0","0","1","1"]]
Out: 3

Case #2

In: grid = [["1"]]
Out: 1

Mastery Tags

Arrays Graphs Matrix

Hiring Companies

Amazon Google Meta
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude