mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-06-04 02:21:15 +08:00
routine
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
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]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user