1342. Number of Steps to Reduce a Number to Zero
On This Page
class Solution:
def numberOfSteps(self, num: int) -> int:
if num == 0:
return 0
return 1 + (
self.numberOfSteps(num // 2)
if num % 2 == 0
else self.numberOfSteps(num - 1)
)