Given an integer num, return the number of steps needed to bring it down to zero. In one step, if the current number is even you divide it by 2, otherwise you subtract 1 from it.
Given an integer num, return the number of steps needed to bring it down to zero. In one step, if the current number is even you divide it by 2, otherwise you subtract 1 from it.
Example 1:
Input: {"num":14}
Output: 6
Constraints:
0≤num≤106
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"num":14}
num = 14 is 1110 in binary: 3 one-bits to clear and 3 shifts to empty the number.