Number of Steps to Reduce a Number to Zero
Easy · Bit Manipulation · about 5 minutes
Asked at Google, Amazon, Microsoft, Bloomberg.
Given a non-negative integer num, repeatedly divide it by 2 if it's even, or subtract 1 if it's odd. Return the number of steps to reach 0.