problem :: https://hack.codingblocks.com/contests/c/255/135
my soln :: https://ide.codingblocks.com/#/s/22549
I am getting correct output for sample input and some other i tried.but i cant pass any of the test cases.Please tell the mistake
thanks
problem :: https://hack.codingblocks.com/contests/c/255/135
my soln :: https://ide.codingblocks.com/#/s/22549
I am getting correct output for sample input and some other i tried.but i cant pass any of the test cases.Please tell the mistake
thanks
Your logic is wrong. It is not giving correct answer for many inputs. For example, the correct answer for input 7 should be 3 (4+2+1=7), but your code gives output 4.
In this question, basically you just need to count the set bits of the binary representation of the number.
The set bits in the binary representation would correspond to the steps that Hulk should take!
ohkay! thanks .got it