image_2022-05-11_10-59-02.png
32.9 KB
#N2206. Divide Array Into Equal Pairs
problem link
#solution
problem link
#solution
class Solution {
public boolean divideArray(int[] nums) {
Map<Integer, Integer> map = new HashMap<>();
for(int num: nums){
map.put(num, map.getOrDefault(num, 0) +1);
}
for(Map.Entry<Integer, Integer> entry: map.entrySet()){
if(entry.getValue()%2!=0) return false;
}
return true;
}
}🔥2