文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
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] = 1else:return Falsereturn True
Reference
- https://leetcode.com/problems/unique-number-of-occurrences/