mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-06-04 02:21:15 +08:00
28 lines
386 B
Go
28 lines
386 B
Go
package A
|
|
|
|
import (
|
|
"slices"
|
|
)
|
|
|
|
var cache = []byte("0")
|
|
|
|
func init() {
|
|
for range 20 {
|
|
temp := append([]byte(nil), cache...)
|
|
for i := range len(temp) {
|
|
if temp[i] == '1' {
|
|
temp[i] = '0'
|
|
} else {
|
|
temp[i] = '1'
|
|
}
|
|
}
|
|
slices.Reverse(temp)
|
|
cache = append(cache, '1')
|
|
cache = append(cache, temp...)
|
|
}
|
|
}
|
|
|
|
func findKthBit(n int, k int) byte {
|
|
return cache[k-1]
|
|
}
|