s4553711
1/5/2018 - 3:30 PM

217.cpp

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;
    }
};