python-algorithm

leetcode 1207. Unique Number of Occurrences

무적김두칠 2022. 3. 22. 13:40

1
2
3
4
5
6
7
class Solution:
    def uniqueOccurrences(self, arr: List[int]) -> bool:
        setArr=list(set(arr))
        ans=[]
        for i in setArr: ans.append(arr.count(i))
        if sorted(ans)== sorted(list(set(ans))): return True
        else : return False
cs
반응형