645. Set Mismatch
class Solution { public: vector<int> findErrorNums(vector<int>& nums) { for (int i = 0; i < nums.size(); i++) while (nums[i] != i+1 && nums[i] != nums[nums[i]-1]) swap(nums[i], nums[nums[i]-1]); int res = 0; for (; nums[res] == res+1; res++); return vector<int>({nums[res], res+1}); } };