Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 07cf0e9

Browse files
committed
created another solution for problem67
1 parent 94f07af commit 07cf0e9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

problem67/Solution0.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int[] countBits(int n) {
3+
int[] ans = new int[n+1];
4+
int offset = 1;
5+
6+
for (int i = 1; i <= n; i++) {
7+
if ((offset << 1) == i) offset = i;
8+
ans[i] = 1 + ans[i-offset];
9+
}
10+
11+
return ans;
12+
}
13+
}

0 commit comments

Comments
 (0)