Skip to main content
Back to problems
Leetcode
Easy
Arrays
Hash Maps
Sets
Unique Number Of Occurrences

Determine whether every distinct value in an array occurs a unique number of times.

Acceptance 0%
Problem Statement

Given an integer array, count how many times each distinct value appears. Return whether all occurrence counts are different from one another.

In other words, no two distinct values should have the same frequency in the array.

Input Format

  • An integer array arr.
  • The array may contain positive, negative, or zero values.

Output Format

  • Return true if the frequency of every distinct value is unique.
  • Otherwise, return false.

Constraints

  • Use the array as given; do not reorder or modify the logical meaning of the elements.
  • The array may be empty.
  • A linear-time solution is expected.
Examples
Sample cases returned by the problem API.

Example 1

Input

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

Output

true

Explanation

Frequencies are 1→3, 2→2, and 3→1. All counts are distinct.

Example 2

Input

arr = [1,2]

Output

false

Explanation

Both 1 and 2 appear once, so the frequency 1 is repeated.

Show 1 more example

Example 3

Input

arr = [-3,0,1,-3,1,1,1,-3,10,0]

Output

true

Explanation

Frequencies are -3→3, 0→2, 1→4, and 10→1. No two values share the same count.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.