• + 0 comments

    CPP

    int sockMerchant(int n, vector<int> ar) {
        unordered_map<int, int> hashmap;
        
        for (int num : ar) {
            hashmap[num]++;
        }
        
        int total = 0;
        for (auto [num, count]: hashmap) {
            total += count / 2;
        }
        
        return total;
    }