From 62acda6cf7a19cf843a911da151e2bfe0c722a7a Mon Sep 17 00:00:00 2001 From: wolves Date: Tue, 3 Mar 2026 15:12:45 +0800 Subject: [PATCH] routine --- 26/03/1545.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 26/03/1545.go diff --git a/26/03/1545.go b/26/03/1545.go new file mode 100644 index 0000000..9f60e19 --- /dev/null +++ b/26/03/1545.go @@ -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] +}