
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.
In a array
A
of size2N
, there areN+1
unique elements, and exactly one of these elements is repeatedN
times.Return the element repeated
N
times.Example 1:
Example 2:
Example 3:
Note:
4 <= A.length <= 10000
0 <= A[i] < 10000
A.length
is even这道题说是有一个长度为 2N 的数组A,里面有 N+1 个不同的数,而且有一个数字正好重复了N次,让找出这个重复了N次的数字。并不是一道难题,可以直接使用一个 HashMap 来统计每个数字出现的个数,只要某个数字出现了 N 次即符合题意返回即可。但这里我们可以进一步的优化一下,由于只有一个数字有重复,其他的都是不重复的,所以只要发现某个数字出现次数大于1次,就可以直接返回了,参见代码如下:
解法一:
由于这道题数组的特殊性,有一半的数字是重复的,所以只要某个相连的三个数字出现重复数字,就一定为所求。这里为了避免 index 溢出,从第三个数字开始遍历,每次找和前两个数字是否出现重复,若有重复则直接返回该数字。但也有遍历完了没有出现重复的情况,只有 [x, x, y, z] 或 [x, y, z, x] 这两种情况,直接返回第一个数字即可,参见代码如下:
解法二:
Github 同步地址:
#961
参考资料:
https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
https://leetcode.com/problems/n-repeated-element-in-size-2n-array/discuss/208317/C%2B%2B-2-lines-O(4)-or-O-(1)
https://leetcode.com/problems/n-repeated-element-in-size-2n-array/discuss/208563/JavaC%2B%2BPython-O(1)-Solution
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: