C++ 33ms , beats 85%


  • 0
    H
    class Solution {
    public:
        bool containsDuplicate(vector<int>& nums) {
            unordered_set<int> dup;
            for(int x : nums){
                if(dup.count(x) == 1) return true;
                dup.insert(x);
            }
            return false;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.