Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/Bit Manipulation/HammingWeightsOfIntegersDp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down