Why are all the test cases failing?Pls check my code. What are the other constraints possible

Plsss check my code.

hello @gvspraveen113
i have checked ur code.
basically u r taking only one step in some powers of 2. and then u are taking linear step which is not correct.

if u observe carefully.
for n-> 23 ( binary 10111)
16 -> 2^4 (10000)
then 4 steps from here i,e 16+4 .
4 -> 2^2
then 2 steps from here i,e 16+4+2 .
2->2^1
then 1 steps from here i,e 16+4+2+1 .
1-> 2^0.
if u obseve 16 + 4 + 2 + 1 is nothing but sum of weights of set bit in 23.
so u only need to print count of set bits.
cout<<builinpopcount(N) will be ur answer
video editorial->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.