Number of Islands
Given a 2D grid of '1's (land) and '0's (water), return the number of islands. Cells connect only horizontally and vertically, and cells outside the grid are water.
Constraints:
- `1 <= rows,...
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:
