leetcode448 C++ 124ms 找到消失的数字
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int>& nums) {
vector<int> res;
int m;
for(int i=0;i<nums.size();i++){
m = abs(nums[i]) - 1;
if(nums[m] > 0){
nums[m] *= -1;
}
}
for(int i=0;i<nums.size();i++){
if(nums[i] > 0){
res.push_back(i+1);
}
}
return res;
}
};