
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
In a 2D grid of
0
s and1
s, we change at most one0
to a1
.After, what is the size of the largest island? (An island is a 4-directionally connected group of
1
s).Example 1:
Example 2:
Example 3:
Notes:
1 <= grid.length = grid[0].length <= 50
.0 <= grid[i][j] <= 1
.这道题在只有0和1的矩阵中用相连的1来表示小岛,现在说是有一个把0变为1的机会,这样原本不相邻的岛就有可能变的相邻了,从而组成一个更大的岛,让求出可能组成的最大的岛屿的面积,也就是相连的1的个数。在 LeetCode 中关于岛屿的题其实也做过许多,比如 Number of Distinct Islands II,Max Area of Island,Number of Distinct Islands,Number of Islands II,和 Number of Islands。其实大多题目的本质都是用 DFS 或者 BFS 去遍历所有相连的1,当然这道题也不例外。博主最开始的想法是首先用 DFS 来找出每个岛屿,然后把同一个岛屿的位置坐标都放到同一个 HashSet 中,这样就有了很多 HashSet,然后遍历所有的0的位置,对每个0位置,遍历其周围4个邻居,然后看邻居位置有没有属于岛屿的,有的话就把该岛屿的 HashSet 编号记录下来,遍历完4个邻居后,在把所有的相连的岛屿中的1个数加起来(因为 HashSet 可以直接求出集合中数字的总个数),每次更新结果 res 即可。这种方法是可以通过 OJ 的,速度还比下面展示的两种方法要快,就是代码比较长,没有下面方法的简洁,这里就不贴了。下面的这两种方法其实都是从每个0开始处理,先把0替换成1,然后再用 DFS 来找所有相连的1的个数,具体如何找就跟之前的岛屿的题目没啥区别了,这里就不细讲了,参见代码如下:
解法一:
当然我们也可以用 BFS 来找所有相连的1的个数,整个的解题思路和上面的解法并没有什么不同,并不难理解,这可能就是论坛上会有人质疑这道题不应该标为 Hard 的原因,参见代码如下:
解法二:
Github 同步地址:
#827
类似题目:
Number of Distinct Islands II
Max Area of Island
Number of Distinct Islands
Number of Islands II
Number of Islands
参考资料:
https://leetcode.com/problems/making-a-large-island/
https://leetcode.com/problems/making-a-large-island/discuss/313787/Two-java-solutions
https://leetcode.com/problems/making-a-large-island/discuss/127256/DFS-JAVA-AC-CONCISE-SOLUTION
https://leetcode.com/problems/making-a-large-island/discuss/127015/C%2B%2B-O(n*m)-15-ms-colorful-islands
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: