Unique Frequency Check

Hashmap Frequency Easy Coding

Unique Frequency Check

Given an array of integers, determine whether the frequency of each distinct element is unique. That is, no two different numbers should have the same count of occurrences.

Problem Details

  • You are given an array of integers.
  • Your task is to check if the number of times each distinct element appears in the array is unique.

Example

For the array: [1, 2, 2, 1, 1, 3]

  • Frequency of 1 is 3.
  • Frequency of 2 is 2.
  • Frequency of 3 is 1.

Since all frequencies are unique (3, 2, and 1), the function should return true.

For the array: [1, 2, 2, 3, 3]

  • Frequency of 1 is 1.
  • Frequency of 2 is 2.
  • Frequency of 3 is 2.

Frequencies 2 appears twice, so the function should return false.

Constraints

  • The array length will be at least 1.
  • Aim to solve this problem using hash maps (or dictionaries) for counting occurrences.

Note

This problem is a perfect practice for utilizing hash map techniques to solve frequency counting challenges. Enjoy coding and have a great day on this special February day!