< Back





1207. Unique Number of Occurrences

For this one, we're returning a boolean if the frequency of each integer within the input array is
unique.

The solution is as follows:


  from collections import Counter

  class Solution:
      def uniqueOccurrences(self, arr: List[int]) -> bool:
          counts = Counter(arr).values()
          return len(counts) == len(set(counts))


_ Time Complexity:

  O(n) - We have to iterate through the entire input array to count frequencies.

_ Space Complexity:

  O(n) - We store the frequency of each number in the input array.