美文网首页Leetcode
Leetcode 1207. Unique Number of

Leetcode 1207. Unique Number of

作者: SnailTyan | 来源:发表于2021-07-26 08:35 被阅读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] = 1
            else:
                return False
        return True

Reference

  1. https://leetcode.com/problems/unique-number-of-occurrences/

相关文章

网友评论

    本文标题:Leetcode 1207. Unique Number of

    本文链接:https://www.haomeiwen.com/subject/qxwfpltx.html