• + 0 comments
    public static int sockMerchant(int n, List<Integer> ar) {
        int[] count = new int[101];
        int pairs = 0;
    
        for(int i = 0; i < ar.size(); i++) {
            count[ar.get(i)]++;
        }
    
        for(int i = 1; i < 101; i++) {
            pairs += count[i]/2;
        }
    
        return pairs;
    }****