
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.
Your friend is typing his
name
into a keyboard. Sometimes, when typing a characterc
, the key might get long pressed , and the character will be typed 1 or more times.You examine the
typed
characters of the keyboard. ReturnTrue
if it is possible that it was your friends name, with some characters (possibly none) being long pressed.Example 1:
Example 2:
Example 3:
Example 4:
Note:
name.length <= 1000
typed.length <= 1000
name
andtyped
are lowercase letters.这道题说是你朋友在用键盘敲入名字的时候,对于某个字母可能会长时间按键,这导可能会有多个相同字母输入,这种情况是允许的,现在给了两个字符串,name 是朋友的名字,typed 是朋友敲入的字符串,问 typed 是否是朋友敲入的名字。其实这道题的本质是,对于 name 中每个位置的字母,对应在 typed 中的出现次数一定要相等或者更多,但是直接统计每个字符出现的次数是不对的,因为位置关系很重要,比如 abb 和 abab,虽然后者中a和b的出现次数都大于等于前者,但还是要返回 false。博主最先想的方法是用两个指针i和j分别提取 name 和 typed 字符串中每个字母出现的次数,如果 typed 中的次数小于 name 中的次数,则直接返回 false 即可,最终循环结束后,i和j应该分别为 name 和 typed 的长度,此时返回 true,否则返回 false,参见代码如下:
解法一:
可以写的简洁一些,不需要使用那么多的 while 循环,而是直接用j遍历 typed 中每个字母,i初识时指向 name 的第一个字母,假如i小于m,且 name[i] 等于 typed[j-1] 时,则i自增1,否则的话,若此时j为0(说明第一个字母就不匹配),或者 typed[j] 不等于 typed[j - 1](说明出现了无法匹配的新字母),则直接返回 false。循环退出后若i等于m则返回 true,否则返回 false,参见代码如下:
解法二:
Github 同步地址:
#925
参考资料:
https://leetcode.com/problems/long-pressed-name/
https://leetcode.com/problems/long-pressed-name/discuss/183994/C%2B%2BJavaPython-Two-Pointers
https://leetcode.com/problems/long-pressed-name/discuss/183929/C%2B%2B-2-lines-accepted-and-5-lines-accurate
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: