
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.
Find the minimum length word from a given dictionary
words
, which has all the letters from the stringlicensePlate
. Such a word is said to complete the given stringlicensePlate
Here, for letters we ignore case. For example,
"P"
on thelicensePlate
still matches"p"
on the word.It is guaranteed an answer exists. If there are multiple answers, return the one that occurs first in the array.
The license plate might have the same letter occurring multiple times. For example, given a
licensePlate
of"PP"
, the word"pair"
does not complete thelicensePlate
, but the word"supper"
does.Example 1:
Example 2:
Note:
licensePlate
will be a string with length in range[1, 7]
.licensePlate
will contain digits, spaces, or letters (uppercase or lowercase).words
will have a length in the range[10, 1000]
.words[i]
will consist of lowercase letters, and have length in range[1, 15]
.这道题给了我们一个车牌号,还有一些单词,让我们找出包含这个车牌号中所有字母的第一个最短的单词。车牌中的字母有大小写之分,但是单词只是由小写单词组成的,所以需要把车牌号中的所有大写字母都转为小写的,转换方法很简单,ASCII码加上32即可。我们建立车牌中各个字母和其出现的次数之间的映射,同时记录所有字母的个数total,然后遍历所有的单词,对于每个单词都要单独处理,我们遍历单词中所有的字母,如果其在车牌中也出现了,则对应字母的映射减1,同时还需匹配的字母数cnt也自减1,最后遍历字母完成后,如果cnt为0(说明车牌中所有的字母都在单词中出现了),并且结果res为空或长度大于当前单词word的话,更新结果即可,参见代码如下:
解法一:
如果这道题的单词是按长度排序的话,那么上面的方法就不是很高效了,因为其会强制遍历完所有的单词。所以我们考虑给单词排序,博主这里用了TreeMap这个数据结构建立单词长度和包含所有该长度单词的数组之间的映射,其会自动按照单词长度来排序。然后还使用了一个chars数组来记录车牌中的所有字母,这样就可以方便的统计出字母总个数。我们从单词长度等于字母总个数的映射开始遍历,先检验该长度的所有单词。这里检验方法跟上面略有不同,但都大同小异,用一个bool型变量succ,初始化为true,然后建立一个字母和其出现次数的映射,先遍历单词,统计各个字母出现的次数。然后就遍历chars数组,如果chars中某个字母不在单词中,那么succ赋值为false,然后break掉。最后我们看succ,如果仍为true,直接返回当前单词word,之后的单词就不用再检验了,参见代码如下:
解法二:
参考资料:
https://discuss.leetcode.com/topic/114155/java-c-clean-code
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: