Kindly check my code

hello @Manvik-Arya-4391661007540658

image
there is logical mistake in ur code .
u should always try to take longest jump possible to minimize the number of steps.

what should be the answer if n=7?

answer shoud be 3.
and the steps are-> 4 + 2 + 1 (i,e 2^2 + 2^1+2^0)

solution is straight forward,u just have to print number of set bit in n.

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.