Convert the occurences .values() into a set, and check if it’s same as the number of keys .keys(). If it’s same that means there’s no two frequencies that are same.

Code

Python3

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

Big O Analysis

  • Runtime

    The runtime complexity here is since that’s the cost of converting a list to a set.

  • Memory

    The memory usage is since we use set().

— A

GitHub | Twitter