Skip to content

Commit 1a2c911

Browse files
committed
添加 1207 独一无二的出现次数 Go 版本
1 parent ca85e56 commit 1a2c911

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

problems/1207.独一无二的出现次数.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ class Solution:
135135

136136

137137
Go:
138+
```Go
139+
func uniqueOccurrences(arr []int) bool {
140+
count := make(map[int]int) // 统计数字出现的频率
141+
for _, v := range arr {
142+
count[v] += 1
143+
}
144+
fre := make(map[int]struct{}) // 看相同频率是否重复出现
145+
for _, v := range count {
146+
if _, ok := fre[v]; ok {
147+
return false
148+
}
149+
fre[v] = struct{}{}
150+
}
151+
return true
152+
}
153+
```
138154

139155
JavaScript:
140156
``` javascript

0 commit comments

Comments
 (0)