0% found this document useful (0 votes)
82 views1 page

Number of Islands - LeetCode

The document describes the "Number of Islands" LeetCode problem. The problem asks you to count the number of islands in a 2D grid where land is represented by 1s and water by 0s. An island is defined as adjacent (horizontally or vertically connected) land. The edges of the grid are surrounded by water. Two examples are provided, where the first grid has 1 island and the second has 3 islands.

Uploaded by

jon monroe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views1 page

Number of Islands - LeetCode

The document describes the "Number of Islands" LeetCode problem. The problem asks you to count the number of islands in a 2D grid where land is represented by 1s and water by 0s. An island is defined as adjacent (horizontally or vertically connected) land. The edges of the grid are surrounded by water. Two examples are provided, where the first grid has 1 island and the second has 3 islands.

Uploaded by

jon monroe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

9/27/2019 Number of Islands - LeetCode

new
Explore Problems Mock Contest Articles Discuss Store Premium

Description Solution Submissions Discuss (999+) C++

. 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

Accepted 431,877 Submissions 1,004,739

Contributor

Companies

Related Topics

Similar Questions
Console

Problems Pick One Prev 200/1205 Next Run Code

https://leetcode.com/problems/number-of-islands/ 1/1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy