Skip to content

Commit 80fd3c6

Browse files
committed
Add Java solution for day28: Counting Bits
1 parent 17328a3 commit 80fd3c6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int[] countBits(int num) {
3+
int[] res = new int[num+1];
4+
for (int i = 1; i <= num; i++) {
5+
res[i] = res[i >> 1] + i % 2;
6+
}
7+
8+
return res;
9+
}
10+
}

0 commit comments

Comments
 (0)