Unique Occurrences
Count how many times each distinct value appears in arr. Return True if all of those counts are different from each other, otherwise False.
Example 1
arr [1,2,2,1,1,3]
returns true
1 appears 3 times, 2 twice, 3 once: all different.
Example 2
arr [1,2]
returns false
Both appear once, so the counts match.
Constraints
1 <= len(arr) <= 40-20 <= arr[i] <= 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Widest Spread ValueEasy
- Bulls and CowsMedium
- Contiguous ArrayMedium
- Group AnagramsMedium
- Longest Consecutive SequenceMedium
- Longest Zero-Sum StretchMedium
- Rows That Match ColumnsMedium
- Shift FamiliesMedium