Tap here to switch tabs
Problem
Submissions

Problem: Number of Steps to Reduce a Number to Zero

Number of Steps to Reduce a Number to Zero asks you to count the operations needed to reach zero, dividing even values by two and subtracting one from odd values.

Statement

Given an integer num, return the number of steps required to reduce it to 00.

In each step, if the current value of num is even, divide it by 22. Otherwise, subtract 11 from it.

Constraints:

  • 0≤0 \leq num ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Steps to Reduce a Number to Zero

Number of Steps to Reduce a Number to Zero asks you to count the operations needed to reach zero, dividing even values by two and subtracting one from odd values.

Statement

Given an integer num, return the number of steps required to reduce it to 00.

In each step, if the current value of num is even, divide it by 22. Otherwise, subtract 11 from it.

Constraints:

  • 0≤0 \leq num ≤106\leq 10^6