Number of Islands - LeetCode
Number of Islands - LeetCode
new
Explore Problems Mock Contest Articles Discuss Store Premium
. Number of Islands
Medium 3192 114 Favorite Share 1▾ class Solution
2 public:
3▾ int
numIslands(vec
Given a 2d grid map of '1' s (land) and '0' s (water), count the number of islands.
grid) {
An island is surrounded by water and is formed by connecting adjacent lands 4
horizontally or vertically. You may assume all four edges of the grid are all 5 }
6 };
surrounded by water.
Example 1:
Input:
11110
11010
11000
00000
Output: 1
Example 2:
Input:
11000
11000
00100
00011
Output: 3
Contributor
Companies
Related Topics
Similar Questions
Console
https://leetcode.com/problems/number-of-islands/ 1/1