We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e9e49f4 commit 04fe403Copy full SHA for 04fe403
counting-bits/yeonguchoe.go
@@ -0,0 +1,11 @@
1
+func countBits(n int) []int {
2
+ var result []int = make([]int, n+1)
3
+ var offset int = 1
4
+ for i := 1; i <= n; i++ {
5
+ if i == offset*2 {
6
+ offset = offset * 2
7
+ }
8
+ result[i] = 1 + result[i-offset]
9
10
+ return result
11
+}
0 commit comments