add new solutions

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

View file

@ -0,0 +1,22 @@
package q137
func singleNumber(nums []int) int {
bitCounts := make([]uint8, 32)
for _, num := range nums {
num32 := int32(num)
for i := range 32 {
if num32|1<<i == num32 {
bitCounts[i] = (bitCounts[i] + 1) % 3
}
}
}
var ret int32
for i := range 32 {
if bitCounts[i] != 0 {
ret |= 1 << i
}
}
return int(ret)
}
var _ = singleNumber