leetcode 448. 找到所有数组中消失的数字
作者:互联网
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int>& nums) {
for(auto num : nums) {
if(nums[abs(num) - 1] >= 0) nums[abs(num) - 1] *= -1;
}
vector<int> ans;
for(int ii = 0; ii < nums.size(); ii++) {
if(nums[ii] > 0) ans.push_back(ii + 1);
}
return ans;
}
};
标签:vector,448,abs,nums,ii,num,数组,ans,leetcode 来源: https://blog.csdn.net/m0_37454852/article/details/115048208