Number of Islands

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

An island is formed by horizontally or vertically adjacent land cells. Cells outsid...

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: