My c++ solution using unordered_set<int>


  • 5
    Y
        unordered_set<int> mySet;
        for(int i = 0;i < nums.size();++i){
            if(mySet.find(nums[i]) == mySet.end()) mySet.insert(nums[i]);
            else mySet.erase(nums[i]);
        }
        auto it = mySet.begin();
        return *it;

Log in to reply
 

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