- Unique Number of Occurrences
Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise.
var uniqueOccurrences = function(arr) {
const num2count = {}
for (let i = 0; i < arr.length; i++) {
num2count[arr[i]] = (num2count[arr[i]] || 0) + 1
}
const count2num = {}
for (const num in num2count) {
if (num2count[num] in count2num) {
return false
}
count2num[num2count[num]] = num
}
return true
};