1. Description
2. Solution
**解析:**Version 1,先统计数字数量,再用map
或set
判断数量是否重复。
- Version 1
class Solution:
def uniqueOccurrences(self, arr: List[int]) -> bool:
stat = collections.Counter(arr)
temp = {}
for value in stat.values():
if value not in temp:
temp[value] = 1
else:
return False
return True
Reference
- https://leetcode.com/problems/unique-number-of-occurrences/