diff --git "a/problems/1207.\347\213\254\344\270\200\346\227\240\344\272\214\347\232\204\345\207\272\347\216\260\346\254\241\346\225\260.md" "b/problems/1207.\347\213\254\344\270\200\346\227\240\344\272\214\347\232\204\345\207\272\347\216\260\346\254\241\346\225\260.md" index 83ebbcb7bc..2ccd30c376 100644 --- "a/problems/1207.\347\213\254\344\270\200\346\227\240\344\272\214\347\232\204\345\207\272\347\216\260\346\254\241\346\225\260.md" +++ "b/problems/1207.\347\213\254\344\270\200\346\227\240\344\272\214\347\232\204\345\207\272\347\216\260\346\254\241\346\225\260.md" @@ -200,10 +200,30 @@ function uniqueOccurrences(arr: number[]): boolean { }) return countMap.size === new Set(countMap.values()).size; }; +``` + + +### 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 +} ``` +