Created
January 15, 2018 13:58
-
-
Save s4553711/e50a34cb97047cab43e2336fe4c412ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
vector<int> findDuplicates(vector<int>& nums) { | |
vector<int> res; | |
for(int i = 0; i < nums.size(); i++) { | |
nums[abs(nums[i]) - 1] = -nums[abs(nums[i]) - 1]; | |
if (nums[abs(nums[i]) - 1] > 0) res.push_back(abs(nums[i])); | |
} | |
return res; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment