All problems

Unique Number of Occurrences

Easy · hash map

A survey records one answer per person as a whole number, and the answers are stored in the list arr. Count how many times each distinct answer appears.

Return true if no two different answers appear the same number of times, and false otherwise.

Examples

Example 1

Input: arr = [4, 4, 4, 7, 7, 9]

Output: true

The value 4 appears 3 times, 7 appears 2 times and 9 appears once. All three counts differ.

Example 2

Input: arr = [1, 1, 2, 2, 3]

Output: false

Both 1 and 2 appear twice.

Example 3

Input: arr = [5]

Output: true

There is only one value, so there is nothing to clash with.

Constraints