1
2
3
4
5
6
7
8
|
class Solution:
def numberOfSteps(self, num: int) -> int:
cnt=0
while num!=0:
if num%2==0: num//=2
else: num-=1
cnt+=1
return cnt
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1678. Goal Parser Interpretation (0) | 2021.07.16 |
---|---|
Leetcode 1389. Create Target Array in the Given Order (0) | 2021.07.16 |
Leetcode 1281. Subtract the Product and Sum of Digits of an Integer (0) | 2021.07.15 |
Leetcode 1528. Shuffle String (0) | 2021.07.15 |
Leetcode 1365. How Many Numbers Are Smaller Than the Current Number (0) | 2021.07.15 |
댓글