48ms 3-line Python solution


  • 0
    R
    class Solution(object):
        def addDigits(self, num):
            num = str(num)
            while len(num) > 1: num = str(reduce(operator.add, map(int, list(num))))
            return int(num)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.