Number of Islands

Given a 2D grid containing only '0' and '1', where '1' represents land and '0' represents water, return the number of islands. Land cells connected horizontally or vertically belong to the sam...

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: