重复元素系列题了:leetcode题目总结_zj-CSDN博客
class Solution {
public:
vector<int> findDuplicates(vector<int>& nums) {
vector<int> res;
int n = nums.size();
for(int i = 0; i < n; ++i){
if(nums[abs(nums[i])-1] < 0)
res.push_back(abs(nums[i]));
else nums[abs(nums[i])-1] *= -1;
}
return res;
}
};