LeetCode June Challenge - Day 22

Problem: LeetCode June Challenge - Day 22

Solution:

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        unordered_map<int,int> m;
        for(int x : nums) m[x]++;
        for(auto pp : m)
            if(pp.second == 1)
                return pp.first;
        return -1;
    }
};