
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 integer array
numssorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.Example 1:
Example 2:
Constraints:
1 <= nums.length <= 104-104 <= nums[i] <= 104numsis sorted in non-decreasing order.这道题给了一个非降序排列的数组,可以有负数存在,现在让求出每个数字的平方数,并且也是非降序排列。若数组中只有正数存在的话,则平方后的数组跟原数组的顺序还是相同的。但是负数的平方是正数,则顺序就会被打乱。最简单暴力的方法就是把平方数存入一个 TreeSet,利用其自动排序的功能可以得到所求的顺序了,注意这里需要用 multiset,因为可能存在重复值,参见代码如下:
解法一:
当然若想进一步优化时间复杂度的话,可以使用双指针来做,用两个变量分别指向开头和结尾,然后比较,每次将绝对值较大的那个数的平方值先加入数组的末尾,然后依次往前更新,最后得到的就是所求的顺序,参见代码如下:
解法二:
Github 同步地址:
#977
类似题目:
Sort Transformed Array
Merge Sorted Array
参考资料:
https://leetcode.com/problems/squares-of-a-sorted-array/
https://leetcode.com/problems/squares-of-a-sorted-array/discuss/221922/Java-two-pointers-O(N)
https://leetcode.com/problems/squares-of-a-sorted-array/discuss/495394/C%2B%2B%3A-Simplest-one-pass-two-pointers
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: