• + 0 comments

    C++ Solution:

    int sockMerchant(int n, vector<int> ar) {
        map<int, int> mp;
        int pair = 0;
        for(int color : ar){
            mp[color]++;
            if(mp[color]%2 == 0){
                pair++;
            }
        }
        return pair;
    }