
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 integers
a
andb
, return any strings
such that:s
has lengtha + b
and contains exactlya
'a'
letters, and exactlyb
'b'
letters,'aaa'
does not occur ins
, and'bbb'
does not occur ins
.Example 1:
Example 2:
Constraints:
0 <= a, b <= 100
s
exists for the givena
andb
.这道题给了两个正数a和b,让返回一个长度为 a+b 的字符串,且只由字符a和b组成,要求不能有三个连着的a或b出现,题目说了对于给定的a和b,一定会有正确的解,让返回一种正确的形式就可以了。题目中给了两个例子来帮助理解,可以发现,a和b的大小关系并不确定,无非也就三种,大于等于和小于,最简单的是相等的时候,直接交替排列即可,虽说可能也存在其他合理的排法,但是没有必要,只要返回的是合理的就行了。接下来就要看不等的情况,比较极端的情况就是a和b中有一个为0,这样直接返回另一个字符组成的字符串就行了,另一个字符的个数也不会超过两个,因为题目中限定了一定有合理的解。如果a和b都不为0,且不等的时候怎么办,比如a大于b时,那么此时可以用两个a,加一个b,尽量让a和b往相等的方向靠拢,则此时对 a-2 和 b-1 调用递归即可,同理,若b大于a,那么此时可以用两个b,加一个a,也尽量让a和b往相等的方向靠拢,则此时对 a-1 和 b-2 调用递归即可,参见代码如下:
解法一:
当然不想用递归也行,迭代的解法稍微长一些,用个 while 循环,只要a和b中有一个为0了就停止,若a大于b,加上 aab,然后a自减1,若b大于a,则加上 bba,然后b自减1,若a和b相等,则加上 ab,之后a和b分别均减1。循环退出后,若a和b还有值,还得加到结果 res,参见代码如下:
解法二:
Github 同步地址:
#984
参考资料:
https://leetcode.com/problems/string-without-aaa-or-bbb/
https://leetcode.com/problems/string-without-aaa-or-bbb/discuss/226740/Clean-C%2B%2Bpython-solution
https://leetcode.com/problems/string-without-aaa-or-bbb/discuss/227038/C%2B%2B-short-and-simple-solution
https://leetcode.com/problems/string-without-aaa-or-bbb/discuss/226649/JavaC%2B%2B-(and-Python)-simple-greedy
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: