```
class Solution {
public:
vector<int> findErrorNums(vector<int>& nums) {
int t = 0,s=0;
vector<int> res;
for(int i=1;i<=nums.size();i++)
t+=i;
for(int i=0;i<nums.size();i++){
s += abs(nums[i]);
int idx = abs(nums[i]);
if(nums[idx-1] < 0)
res.push_back(idx);
nums[idx-1] *= -1;
}
int diff = t - s;
res.push_back(res[0] + diff);
return res;
}
};
```