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 699a5ba commit 428e617Copy full SHA for 428e617
counting-bits/njngwn.java
@@ -0,0 +1,11 @@
1
+class Solution {
2
+ public int[] countBits(int n) {
3
+ int[] bitCountArr = new int[n+1];
4
+
5
+ for (int i = 1; i <= n; ++i) {
6
+ bitCountArr[i] = bitCountArr[i/2] + (i & 1);
7
+ }
8
9
+ return bitCountArr;
10
11
+}
0 commit comments