Two liner using lambda in python


  • 0
    B
    class Solution(object):
        def addDigits(self, num):
            result = reduce(lambda x, y: x + y, [int(i) for i in str(num)])
            return self.addDigits(result) if result/10 >= 1 else result

Log in to reply
 

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