Unique Number of Occurrences

EasyArrays & Hashinghashing

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

Given an integer array arr, count how many times each distinct value appears. Return true if no two distinct values share the same count, and false otherwise.

Examples

Input: arr = [1,2,2,1,1,3]
Output: true
Counts are 1 -> 3, 2 -> 2, 3 -> 1, and all three counts differ.
Input: arr = [1,2]
Output: false
Both values appear once, so the count 1 is shared.

Constraints

  • 1 <= arr.length <= 1000
  • -1000 <= arr[i] <= 1000

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More hashing problems