AddDigit 썸네일형 리스트형 AddDigit Problem Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. 정수 값이 들어오면 정수값을 포함하고 있는 자리수의 모든 값들의 합이 하나만 남을때까지 반복하여 더하고 그 값을 반환하는 문제 38 → 3 + 8 → 11 → 1 + 1 → 2 → return 2 Solution class Solution: def addDigits(self, num: int) -> int: res = num while res > 9: res_list = list(str(res)) result = 0 for i in res_list: result += int(i) res = result re.. 더보기 이전 1 다음