
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.
We are given the
root
node of a maximum tree: a tree where every node has a value greater than any other value in its subtree.Just as in the previous problem, the given tree was constructed from an list
A
(root = Construct(A)
) recursively with the followingConstruct(A)
routine:A
is empty, returnnull
.A[i]
be the largest element ofA
. Create aroot
node with valueA[i]
.root
will beConstruct([A[0], A[1], ..., A[i-1]])
root
will beConstruct([A[i+1], A[i+2], ..., A[A.length - 1]])
root
.Note that we were not given A directly, only a root node
root = Construct(A)
.Suppose
B
is a copy ofA
with the valueval
appended to it. It is guaranteed thatB
has unique values.Return
Construct(B)
.Example 1:
Example 2:
Example 3:
Constraints:
1 <= B.length <= 100
这道题完全是基于之前那道 Maximum Binary Tree 出的,没做上面这道就不太好理解这道题的意思,简单说一下,之前那道题就是给了一个数组,然后用其中最大的值当作根结点,且左边的子数组递归生成左子树,右边的子数组递归生成右子树。而这道题没有给初始数组,而是给了一个已经按这种方式生成的二叉树,然后说是在生成该二叉树的原数组的后面加上一个数字 val,让返回生成新的二叉树。最笨的方法就是先根据二叉树还原出原数组,然后在加上 val,再次调用 Maximum Binary Tree 中的方法生成的新的二叉树。这种方法可以通过 OJ,但是感觉不太聪明的样子,其实这道题有很简洁的解法,几行就搞定了。由于新的数字 val 一定是加在数组的末尾的,其在数组中的大小关系就变的很重要了,由于数组中的最大值将作为根结点,若 val 是最大值,则其一定是新的根结点,原二叉树直接变成其左子树了,直接就得到了结果。若 val 小于当前数组的最大值,则其一定是在右子树中,则可以对最大值右边的子数组调用递归函数,即对根结点的右子结点调用递归函数,将返回的结点更新为新的右子结点即可,参见代码如下:
Github 同步地址:
#998
类似题目:
Maximum Binary Tree
参考资料:
https://leetcode.com/problems/maximum-binary-tree-ii/
https://leetcode.com/problems/maximum-binary-tree-ii/discuss/242897/Java-clean-recursive-solution
https://leetcode.com/problems/maximum-binary-tree-ii/discuss/242936/JavaC%2B%2BPython-Recursion-and-Iteration
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: