diff --git a/java/Bit Manipulation/HammingWeightsOfIntegersDp.java b/java/Bit Manipulation/HammingWeightsOfIntegersDp.java index 63793d7..d6b6c8a 100644 --- a/java/Bit Manipulation/HammingWeightsOfIntegersDp.java +++ b/java/Bit Manipulation/HammingWeightsOfIntegersDp.java @@ -3,7 +3,7 @@ public int[] hammingWeightsOfIntegersDp(int n) { // Base case: the number of set bits in 0 is just 0. We set dp[0] to // 0 by initializing the entire DP array to 0. int[] dp = new int[n + 1]; - for (int x = 0; x < n + 1; x++) { + for (int x = 1; x < n + 1; x++) { // 'dp[x]' is obtained using the result of 'dp[x >> 1]', plus // the LSB of 'x'. dp[x] = dp[x >> 1] + (x & 1);