Skip to content

Commit 93e06c1

Browse files
committed
Add Counting bits Solution
1 parent cf1925e commit 93e06c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

counting-bits/s0ooo0k.java

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

0 commit comments

Comments
 (0)