
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 the
root
of a binary tree, each node has a value from0
to25
representing the letters'a'
to'z'
: a value of0
represents'a'
, a value of1
represents'b'
, and so on.Find the lexicographically smallest string that starts at a leaf of this tree and ends at the root.
(As a reminder, any shorter prefix of a string is lexicographically smaller: for example,
"ab"
is lexicographically smaller than"aba"
. A leaf of a node is a node that has no children.)Example 1:
Example 2:
Example 3:
Note:
1
and8500
.0
and25
.这道题给了一棵二叉树,说是结点值上的数字对应一个字母,让返回从叶结点到根结点的路径可以组成的字符串中按字母顺序排列最小的那个。其实这道题的本质就是找二叉树的路径,跟之前那道 Binary Tree Paths 一样,从叶结点往回找路径不是很方便,这里还是找从根结点到叶结点的路径,在组成字符串的时候,每次把字符加到前头就可以了,得到的还是从叶结点到根结点的顺序。这里还是使用递归来做,结果 res 初始化为
~
,博主最喜欢用一个表情符号,这么做的原因是其 ASCII 码值是大于z的,所以可以当初始值。在递归函数中,首先判空,否则将当前字符加到 cur 的最前面,然后判断若当前结点是叶结点,则用 cur 来更新结果 res,接下来对左右子结点分别调用递归函数即可,参见代码如下:解法一:
我们也可以稍微写的简洁一些,让递归函数有返回值,递归函数中还要带个参数,首先判空,若为空,则返回
~
。否则将当前字符加到结果 res 前面,然后判断左右结点是否相同,其实就是判断是否均为 null,也就是判断是否是叶结点,是的话就返回 res,否则返回分别对左右子结点调用递归函数得到的较小值,参见代码如下:解法二:
Github 同步地址:
#988
类似题目:
Sum Root to Leaf Numbers
Binary Tree Paths
参考资料:
https://leetcode.com/problems/smallest-string-starting-from-leaf/
https://leetcode.com/problems/smallest-string-starting-from-leaf/discuss/231102/C%2B%2B-3-lines
https://leetcode.com/problems/smallest-string-starting-from-leaf/discuss/231251/Java-2-Concise-DFS-codes-with-comment.
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: