1207. Unique Number of Occurrences
class Solution {
public boolean uniqueOccurrences(int[] arr) {
HashMap h = new HashMap();
for(int i = 0; i < arr.length; i++) {
h.put(arr[i], h.getOrDefault(arr[i],0)+1);
}
if(h.size() == 0) return true;
HashSet repeats = new HashSet();
for (Integer a: h.keySet()) {
if(repeats.contains(h.get(a))) return false;
else repeats.add(h.get(a));
}
return true;
}
}