LeetCode 200: Number of islands
发布时间
阅读量:
阅读量
题目:
给定一个二维网格,在其中包含1和0的空间中计算陆地区域的数量。每个岛屿由被水完全包围,并且其内部由连通的陆地位点构成。该网格的所有边界都被视为水体。
Consider a 2D grid where each cell is marked as '1' for land or '0' for water; determine the total number of islands. An island is entirely surrounded by water, defined as a group of connected land cells that are adjacent either horizontally or vertically. The grid's borders are all considered to be surrounded by water.
示例 1:
输入:
11110
11010
11000
00000
输出: 1
示例 2:
输入:
11000
11000
00100
00011
输出: 3
解题思路:
首先弄清楚什么
全部评论 (0)
还没有任何评论哟~
