
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.
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.
Example:
Explanation:
1. Removing the leaves
[4,5,3]
would result in this tree:2. Now removing the leaf
[2]
would result in this tree:3. Now removing the leaf
[1]
would result in the empty tree:Credits:
Special thanks to @elmirap for adding this problem and creating all test cases.
这道题给了我们一个二叉树,让我们返回其每层的叶节点,就像剥洋葱一样,将这个二叉树一层一层剥掉,最后一个剥掉根节点。那么题目中提示说要用DFS来做,思路是这样的,每一个节点从左子节点和右子节点分开走可以得到两个深度,由于成为叶节点的条件是左右子节点都为空,所以我们取左右子节点中较大值加1为当前节点的深度值,知道了深度值就可以将节点值加入到结果res中的正确位置了,求深度的方法我们可以参见 Maximum Depth of Binary Tree 中求最大深度的方法,参见代码如下:
解法一:
下面这种DFS方法没有用计算深度的方法,而是使用了一层层剥离的方法,思路是遍历二叉树,找到叶节点,将其赋值为NULL,然后加入leaves数组中,这样一层层剥洋葱般的就可以得到最终结果了:
解法二:
还有一种不用建立新的递归函数的方法,就用本身来做递归,我们首先判空,然后对左右子结点分别调用递归函数,这样我们suppose左右子结点的所有叶结点已经按顺序存好到了二维数组left和right中,现在要做的就是把两者合并。但是我们现在并不知道左右子树谁的深度大,我们希望将长度短的二维数组加入到长的里面,那么就来比较下两者的长度,把长度存到结果res中,把短的存入到t中,然后遍历短的,按顺序都加入到结果res里,好在这道题没有强行要求每层的叶结点要按照从左到右的顺序存入。当左右子树的叶结点融合完成了之后,当前结点也要新开一层,直接自己组一层,加入结果res中即可,参见代码如下:
解法三:
类似题目:
Maximum Depth of Binary Tree
Minimum Height Trees
参考资料:
https://leetcode.com/problems/find-leaves-of-binary-tree/
https://leetcode.com/problems/find-leaves-of-binary-tree/discuss/83773/1-ms-Easy-understand-Java-Solution
https://leetcode.com/problems/find-leaves-of-binary-tree/discuss/191609/10%2B-line-Java-solution-using-recursion
https://leetcode.com/problems/find-leaves-of-binary-tree/discuss/83778/10-lines-simple-Java-solution-using-recursion-with-explanation
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: