problem
code
public int numberOfSteps (int num) {
return count(num, 0);
}
public int count(int num, int count) {
if (num == 0) return count;
count++;
if (num % 2 == 0) num /=2;
else num--;
return count(num, count);
}
Time: O(N), ex) 2 => need 2 steps
Space: O(1), just need count