Question: Given an integer num, return the number of steps to reduce it to zero. In one step, if the current number is even, you have
Given an integer num, return the number of steps to reduce it to zero.
In one step, if the current number is even, you have to divide it by otherwise, you have to subtract from it
Example :
Input: num
Output:
Explanation:
Step is even; divide by and obtain
Step is odd; subtract and obtain
Step is even; divide by and obtain
Step is odd; subtract and obtain
Step is even; divide by and obtain
Step is odd; subtract and obtain
Example :
Input: num
Output:
Explanation:
Step is even; divide by and obtain
Step is even; divide by and obtain
Step is even; divide by and obtain
Step is odd; subtract and obtain
Example :
Input: num
Output:
Constraints:
num
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
