Unique Number of Occurrences

Easy

Description

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise.

Examples

Input:arr = [1,2,2,1,1,3]
Output:true
Explanation:

1→3, 2→2, 3→1, all unique.

Input:arr = [1,2]
Output:false
Explanation:

Each value appears once, so occurrence counts are [1, 1]. The counts are not unique.

Input:arr = [5,5,5,7,7,8]
Output:true
Explanation:

Number 5 appears 3 times, number 7 appears 2 times, and number 8 appears 1 time. The occurrence counts are [3,2,1] which are all unique, so return true.

Constraints

  • 1 ≤ arr.length ≤ 1000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!