Whats the error in my code?

Whats the error in my code? Sample test cases passed but wrong answer.
Question : Bitmasking / Incredible Hulk
the link of my code :

your logic is incorrect.

let us try to understand the probleml through an example.
β€œin a single jump, hulk can go at a distance of 2^i for any i.”
examples:

  1. N = 5.
    answer: it need 2 jumps, first jump of length 4 and second of length 1.
    how to solve it?
    what powers of 2 can sum to 5? ans is 2^2 + 2^0 = 4+1 =5.(binary of 5 is 101 i.e. 2 set bits = 2 moves)

  2. N= 22,
    answer : 3 jumps
    how?
    2^4 + 2^2+2^1 = 16+4+2 = 22 (binary form = 10110 i.e. 3 set bits in binary form = 3 moves)

note that the no of 1’s(set bits) in binary form is quickest no of moves to reach N.

thanks