本题可以套用和 [LeetCode] 200. Number of Islands 岛屿的数量 与 [LeetCode 695] Max Area of Island 岛的最大面积一样的dfs模版,不同的是DFS的遍历路径不同,本题 采用的是类似十字遍历方式,具体见如下代码,本题同样可以使用BFS和 ...
分类:
其他好文 时间:
2020-04-13 00:57:47
阅读次数:
63
题目链接:https://leetcode-cn.com/problems/island-perimeter/ 给定一个包含 0 和 1 的二维网格地图,其中 1 表示陆地 0 表示水域。 网格中的格子水平和垂直方向相连(对角线方向不相连)。整个网格被水完全包围,但其中恰好有一个岛屿(或者说,一个或 ...
分类:
其他好文 时间:
2020-03-16 09:50:08
阅读次数:
51
题目链接:https://leetcode-cn.com/problems/max-area-of-island/ 给定一个包含了一些 0 和 1的非空二维数组 grid , 一个 岛屿 是由四个方向 (水平或垂直) 的 1 (代表土地) 构成的组合。你可以假设二维矩阵的四个边缘都被水包围着。 找到 ...
分类:
其他好文 时间:
2020-03-16 09:45:53
阅读次数:
44
题目:https://leetcode cn.com/problems/max area of island/ ...
分类:
其他好文 时间:
2020-03-15 22:09:02
阅读次数:
65
LeetCode 0200. Number of Islands岛屿数量【Medium】【Python】【DFS】 Problem "LeetCode" Given a 2d grid map of s (land) and s (water), count the number of island ...
分类:
编程语言 时间:
2020-02-29 00:19:02
阅读次数:
86
In a given 2D binary array , there are two islands. (An island is a 4 directionally connected group of s not connected to any other 1s.) Now, we may c ...
分类:
其他好文 时间:
2020-02-19 23:40:26
阅读次数:
85
1 """ 2 Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting ...
分类:
其他好文 时间:
2020-02-15 23:28:19
阅读次数:
68
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/02/04 20:08 # @Author : dangxusheng # @Email : dangxusheng163@163.com # @File : isLand_lo ...
分类:
其他好文 时间:
2020-02-05 23:09:40
阅读次数:
244
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo ...
分类:
其他好文 时间:
2020-01-24 09:22:44
阅读次数:
62
"LuoguP4381 [IOI2008]Island" Description 一句话题意:给一个基环树森林,求每棵基环树的直径长度的和(基环树的直径定义与树类似,即基环树上一条最长的简单路径),节点总数不超过$10^6$。 Solution 问题就是如何求基环树的直径。 首先树的直径的话可以直接 ...
分类:
其他好文 时间:
2020-01-23 00:13:50
阅读次数:
60