Number of Islands: DFS and BFS

Given an m × n grid consisting of '1' (land) and '0' (water), return the number of islands.

An island is formed by horizontally or vertically adjacent land cells. The boundary of the grid is su...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: