Split the number into a list of digits using
map(int, str(num)), and take the sum of the digits. Repeat until the resulting number is less than 10.
def addDigits(self, num): while num >= 10: num = sum(map(int, str(num))) return num
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.