Problem LInk:

I don’t know my below code is giving wrong answer

```
public:
vector<int> countBits(int n) {
vector<int> dp(n+1);
dp[0] = 0;
dp[1]=1;
for(int i=2; i<=n;i++){
dp[i] = i%2+ dp[i/2];
}
return dp;
}
};
```

while this one is giving correct answer

```
public:
vector<int> countBits(int n) {
vector<int> dp(n+1);
dp[0] = 0;
for(int i=1; i<=n;i++){
dp[i] = i%2+ dp[i/2];
}
return dp;
}
};
```