
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.
Design and implement a TwoSum class. It should support the following operations:
add
andfind
.add
- Add the number to an internal data structure.find
- Find if there exists any pair of numbers which sum is equal to the value.Example 1:
Example 2:
这道题让我们设计一个 Two Sum 的数据结构,跟 LeetCode 的第一道题 Two Sum 没有什么太大的区别,作为 LeetCode 的首题,Two Sum 的名气不小啊,正所谓平生不会 TwoSum,刷尽 LeetCode 也枉然。记得原来在背单词的时候,总是记得第一个单词是 abandon,结果有些人背来背去还在 abandon,有时候想想刷题其实跟背 GRE 红宝书没啥太大的区别,都是一个熟练功夫,并不需要有多高的天赋,只要下足功夫,都能达到一个很不错的水平,套用一句鸡汤问来激励下吧,“有些时候我们的努力程度根本达不到需要拼天赋的地步”,好了,不闲扯了,来看题吧。不过这题也没啥可讲的,会做 Two Sum 的这题就很简单了,先来看用 HashMap 的解法,把每个数字和其出现的次数建立映射,然后遍历 HashMap,对于每个值,先求出此值和目标值之间的差值t,然后需要分两种情况来看,如果当前值不等于差值t,那么只要 HashMap 中有差值t就返回 True,或者是当差值t等于当前值时,如果此时 HashMap 的映射次数大于1,则表示 HashMap 中还有另一个和当前值相等的数字,二者相加就是目标值,参见代码如下:
解法一:
另一种解法不用 HashMap,而是 unordered_multiset 来做,但是原理和上面一样,参见代码如下:
解法二:
Github 同步地址:
#170
类似题目:
Two Sum
Unique Word Abbreviation
Two Sum IV - Input is a BST
参考资料:
https://leetcode.com/problems/two-sum-iii-data-structure-design/
https://leetcode.com/problems/two-sum-iii-data-structure-design/discuss/52015/Beats-100-Java-Code
https://leetcode.com/problems/two-sum-iii-data-structure-design/discuss/52035/My-solutions-in-Java-C%2B%2B-and-Python.-O(1)-time-for-add-O(n)-time-for-find-O(n)-space
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: