487. Steps to Reduce a Number to Zero
EasySimulationBit Manipulation
If the number is even, halve it; otherwise subtract 1. Print the number of steps to reach 0.
Input format
One integer
Output format
The number of steps.
Example 1
Input
14
Output
6
Example 2
Input
8
Output
4
Constraints
0 ≤ n ≤ 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…