diff --git a/problems/1207.独一无二的出现次数.md b/problems/1207.独一无二的出现次数.md index c1720430..32aa3c3a 100644 --- a/problems/1207.独一无二的出现次数.md +++ b/problems/1207.独一无二的出现次数.md @@ -100,7 +100,21 @@ class Solution { ``` Python: - +```python +class Solution: + def uniqueOccurrences(self, arr: List[int]) -> bool: + count = [0] * 2002 + for i in range(len(arr)): + count[arr[i] + 1000] += 1 # 防止负数作为下标 + freq = [False] * 1002 # 标记相同频率是否重复出现 + for i in range(2001): + if count[i] > 0: + if freq[count[i]] == False: + freq[count[i]] = True + else: + return False + return True +``` Go: JavaScript: