add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent 9a10695e8c
commit ca24d0a56a
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
30 changed files with 697 additions and 16 deletions

View file

@ -0,0 +1,25 @@
package q1207
import "slices"
type void struct{}
func uniqueOccurrences(arr []int) bool {
slices.Sort(arr)
seen := map[int]void{}
for i := 0; i < len(arr); {
c := arr[i]
count := 0
for ; i < len(arr) && arr[i] == c; i++ {
count++
}
if _, ok := seen[count]; ok {
return false
}
seen[count] = void{}
}
return true
}
var _ = uniqueOccurrences