• + 0 comments
        public static int sockMerchant(int n, List<Integer> ar) {
        // Write your code here
            Map<Integer, Integer> map = new HashMap<>();
                
            ar.stream().forEach(val -> {
                if (map.containsKey(val)) {
                    map.remove(val);
                } else {
                    map.put(val, 1);
                }
            });
            
            return (ar.size() - map.keySet().size()) / 2;
        }