Posted on

Description

Submission

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        map<int, int> cnt;

        for(auto x: nums) {
            ++cnt[x];
        }

        for(auto [key, val]: cnt) {
            if(val == 1) return key;
        }

        return -1;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *