mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
添加 1207.独一无二的出现次数python3版本
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user