
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 an array
A
of non-negative integers, return an array consisting of all the even elements ofA
, followed by all the odd elements ofA
.You may return any answer array that satisfies this condition.
Example 1:
Note:
1 <= A.length <= 5000
0 <= A[i] <= 5000
这道题让我们给数组重新排序,使得偶数都排在奇数前面,并不难。最直接的做法就是分别把偶数和奇数分别放到两个数组中,然后把奇数数组放在偶数数组之后,将拼接成的新数组直接返回即可,参见代码如下:
解法一:
我们也可以优化空间复杂度,不新建额外的数组,而是采用直接交换数字的位置,使用两个指针i和j,初始化均为0。然后j往后遍历,若遇到了偶数,则将 A[j] 和 A[i] 交换位置,同时i自增1,这样操作下来,同样可以将所有的偶数都放在奇数前面,参见代码如下:
解法二:
我们还可以使用 STL 的内置函数 partition,是专门用来给数组重新排序的,不过我们要重写排序方式,将偶数的都放在前面即可,参见代码如下:
解法三:
Github 同步地址:
#905
参考资料:
https://leetcode.com/problems/sort-array-by-parity/
https://leetcode.com/problems/sort-array-by-parity/discuss/170734/C%2B%2BJava-In-Place-Swap
https://leetcode.com/problems/sort-array-by-parity/discuss/170725/Know-your-C%2B%2B-Algorithms!-This-is-std%3A%3Apartition-%3A)
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: