FunctionRacerProblemsRace

Unique Occurrences

EasyHash mapsPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems