Skip to content

Commit

Permalink
添加 1207 独一无二的出现次数 Go 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
wangben18 committed Jul 19, 2023
1 parent ca85e56 commit 1a2c911
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions problems/1207.独一无二的出现次数.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ class Solution:


Go:
```Go
func uniqueOccurrences(arr []int) bool {
count := make(map[int]int) // 统计数字出现的频率
for _, v := range arr {
count[v] += 1
}
fre := make(map[int]struct{}) // 看相同频率是否重复出现
for _, v := range count {
if _, ok := fre[v]; ok {
return false
}
fre[v] = struct{}{}
}
return true
}
```

JavaScript:
``` javascript
Expand Down

0 comments on commit 1a2c911

Please sign in to comment.