Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created January 5, 2018 15:30
Show Gist options
  • Save s4553711/f60bebbf54b834a432338ccb9cee5a79 to your computer and use it in GitHub Desktop.
Save s4553711/f60bebbf54b834a432338ccb9cee5a79 to your computer and use it in GitHub Desktop.
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