본문 바로가기
python-algorithm

leetcode 258. Add Digits

by 무적김두칠 2022. 4. 8.

1
2
3
4
5
6
7
8
class Solution:
    def addDigits(self, num: int-> int:
        while num>=10:
            tmp = 0
            for i in (str(num)):
                tmp+=int(i)
            num=tmp
        return (num)
cs
반응형

'python-algorithm' 카테고리의 다른 글

leetcode 1507. Reformat Date  (0) 2022.04.08
leetcode 169. Majority Element  (0) 2022.04.08
leetcode 1550. Three Consecutive Odds  (0) 2022.04.04
leetcode 1800. Maximum Ascending Subarray Sum  (0) 2022.04.04
leetcode 896. Monotonic Array  (0) 2022.03.28

댓글