Skip to content

Commit 04fe403

Browse files
authored
dp로 풀음.
1 parent e9e49f4 commit 04fe403

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

counting-bits/yeonguchoe.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)