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.
2 parents 6af5f77 + 0383e89 commit 1865969Copy full SHA for 1865969
java/counting-bits.md
@@ -81,9 +81,9 @@ public int[] countBits(int n) {
81
for (int i = 1; i <= n; i++) {
82
if (i == pow) {
83
pow *= 2; // Move to the next power of two
84
- x = 1;
+ x = i;
85
}
86
- res[i] = res[x++] + 1; // Use the result from a smaller index plus one
+ res[i] = res[i-x] + 1; // Use the result from a smaller index plus one
87
88
return res;
89
0 commit comments