当前位置: 代码迷 >> 综合 >> Leetcode 1207. Unique Number of Occurrences
  详细解决方案

Leetcode 1207. Unique Number of Occurrences

热度:83   发布时间:2023-12-12 21:04:26.0

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. Description

Unique Number of Occurrences

2. Solution

**解析:**Version 1,先统计数字数量,再用mapset判断数量是否重复。

  • 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

  1. https://leetcode.com/problems/unique-number-of-occurrences/
  相关解决方案