
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.
Give a string
s
, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.Substrings that occur multiple times are counted the number of times they occur.
Example 1:
Example 2:
Note:
s.length
will be between 1 and 50,000.s
will only consist of "0" or "1" characters.这道题给了我们一个二进制字符串,然后我们统计具有相同0和1的个数,且0和1各自都群组在一起(即0和1不能交替出现)的子字符串的个数,题目中的两个例子也很能说明问题。那么我们来分析题目中的第一个例子00110011,符合要求的子字符串要求0和1同时出现,那么当第一个1出现的时候,前面由于前面有两个0,所以肯定能组成01,再遇到下一个1时,此时1有2个,0有2个,能组成0011,下一个遇到0时,此时0的个数重置为1,而1的个数有两个,所以一定有10,同理,下一个还为0,就会有1100存在,之后的也是这样分析。那么我们可以发现我们只要分别统计0和1的个数,而且如果当前遇到的是1,那么只要之前统计的0的个数大于当前1的个数,就一定有一个对应的子字符串,而一旦前一个数字和当前的数字不一样的时候,那么当前数字的计数要重置为1。所以我们遍历元数组,如果是第一个数字,那么对应的ones或zeros自增1。然后进行分情况讨论,如果当前数字是1,然后判断如果前面的数字也是1,则ones自增1,否则ones重置为1。如果此时zeros大于ones,res自增1。反之同理,如果当前数字是0,然后判断如果前面的数字也是0,则zeros自增1,否则zeros重置为1。如果此时ones大于zeros,res自增1。参见代码如下:
解法一:
下面这种方法更加简洁了,不用具体的分0和1的情况来讨论了,而是直接用了pre和cur两个变量,其中pre初始化为0,cur初始化为1,然后从第二个数字开始遍历,如果当前数字和前面的数字相同,则cur自增1,否则pre赋值为cur,cur重置1。然后判断如果pre大于等于cur,res自增1。其实核心思想跟上面的方法一样,只不过pre和cur可以在0和1之间切换,参见代码如下:
解法二:
类似题目:
Encode and Decode Strings
参考资料:
https://discuss.leetcode.com/topic/107096/java-o-n-time-o-1-space
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: