
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 two strings
AandBof lowercase letters, returntrueif and only if we can swap two letters inAso that the result equalsB.Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Note:
0 <= A.length <= 200000 <= B.length <= 20000AandBconsist only of lowercase letters.这道题给了两个字符串A和B,说是我们必须调换A中的两个字符的位置一次,问是否能得到字符串B。这道题给的例子又多又全,基本上把所有的 corner cases 都覆盖了,比如我们对比例子2和例子3,可以发现虽然两个例子中A和B字符串都相等,但是仔细观察的话,可以发现 "ab" 中没有相同的字符,而 "aa" 中有相同的字符,那么实际上 "aa" 是可以调换两个字符的位置的,这样还跟字符串B相等,是符合题意的,因为题目要求必须要调换一次位置,若没有相同的字符,是无法调换位置后和B相等的。
那么我们应该可以总结出一些规律了,首先字符串A和B长度必须要相等,不相等的话直接返回 false。假如起始时A和B就完全相等,那么只有当A中有重复字符出现的时候,才能返回 true。快速检测重复字符的方法就是利用 HashSet 的自动去重复功能,将A中所有字符存入 HashSet 中,若有重复字符,那么最终 HashSet 的大小一定会小于原字符串A的长度。对于A和B长度相等,但是字符串本身不相等的一般情况,我们可以记录出所有对应字符不相同的位置,放到一个数组 diff 中,最终判断 diff 数组的长度是否为2,且判断交换位置后是否跟B中对应的位置上的字符相同即可,参见代码如下:
Github 同步地址:
#859
参考资料:
https://leetcode.com/problems/buddy-strings/
https://leetcode.com/problems/buddy-strings/discuss/141780/Easy-Understood
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: