Unique Number of Occurrences

Given an array of integers arr, return true if the number of times each distinct value appears is different from the number of times every other distinct value appears, and false otherwise.

30:00

Unique Number of Occurrences
easy
Free written solution
Topics
Companies

Given an array of integers arr, return true if the number of times each distinct value appears is different from the number of times every other distinct value appears, and false otherwise.

Example 1:
Input: {"arr":[1,2,2,1,1,3]}
Output: true
Constraints:
  • 1≤arr.length≤10001 \leq \text{arr.length} \leq 1000

  • −1000≤arr[i]≤1000-1000 \leq \text{arr}[i] \leq 1000

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"arr":[1,2,2,1,1,3]}

arr (6)

1
2
2
1
1
3

count map (value: times seen)

empty

Phase 1: count how many times each value appears. Start with an empty tally for 6 elements.

Variables
VariableValue
n6
DepthFunction Call
Stack empty
0/14