728x90
https://leetcode.com/problems/unique-number-of-occurrences
class Solution:
def uniqueOccurrences(self, arr: List[int]) -> bool:
dic = {}
unique = list(set(arr))
for n in unique:
dic[n] = arr.count(n)
if len(set(dic.values())) == len(dic.keys()):
return True
return False
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 961. N-Repeated Element in Size 2N Array (0) | 2024.03.07 |
---|---|
[Leetcode] 2670. Find the Distinct Difference Array (0) | 2024.03.07 |
[Leetcode] 1941. Check if All Characters Have Equal Number of Occurrences (0) | 2024.03.05 |
[Leetcode] 1748. Sum of Unique Elements (0) | 2024.03.04 |
[Leetcode] 2405. Optimal Partition of String (0) | 2024.03.04 |