Divide Array Into Equal Pairs LeetCode solution in Java

1
class Solution {
2
public boolean divideArray(int[] arr) {
3
HashMap<Integer, Integer> map = new HashMap<>();
4

5
for (int i : arr) map.put(i, map.getOrDefault(i, 0) + 1);
6
for (int i : map.keySet()) {
7
if (map.get(i) % 2 != 0) return false;
8
}
9
return true;
10
}
11
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0