添加 1207.独一无二的出现次数python3版本

This commit is contained in:
ironartisan
2021-08-07 21:15:06 +08:00
parent b86c0963b9
commit 660833125d

View File

@ -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