Created
January 5, 2018 15:30
-
-
Save s4553711/f60bebbf54b834a432338ccb9cee5a79 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: | |
bool containsDuplicate(vector<int>& nums) { | |
if (nums.size() == 0) return false; | |
sort(nums.begin(), nums.end()); | |
int cur = -1; | |
for(int i = 0; i < nums.size(); i++) { | |
if (cur != nums[i]) { | |
cur = nums[i]; | |
} else { | |
return true; | |
} | |
} | |
return false; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment