class Solution {
public:
vector countBits(int num) {
vector res(num + 1);
for(int i = 1; i < num + 1; i++) {
if(i % 2 == 0) {
res[i] = res[i >> 1];
}else{
res[i] = res[i >> 1] + 1;
}
}
return res;
}
};
In this problem,https://leetcode.com/problems/counting-bits/
if we are taking the num =5,if the coounting is taken from 1 then its accepted its giving a wrong ans for the count from 0 to 4 ,but if we dont take the cout from 0 then how we will get the 0 in the output list.Please explain me this I am getting confused