1207. 独一无二的出现次数




class Solution(object):
    def uniqueOccurrences(self, arr):
        """
        :type arr: List[int]
        :rtype: bool
        """
        mydict = {}
        for item in arr:
            if item in mydict.keys():
                mydict[item] += 1
            else:
                mydict[item] = 1
        vals = sorted(mydict.values())
        i, j = 0, 1
        while j < len(vals):
            if vals[i] == vals[j]:
                return False
            i += 1
            j += 1
        return True
原文地址:https://www.cnblogs.com/panweiwei/p/14024753.html