Clean python code


  • 0
    class Solution(object):
        def sumNumbers(self, root, r=0):
            if not root:
                return 0
    
            r = r * 10 + root.val
            return sum([self.sumNumbers(c, r) for c in (root.left, root.right)]) or r

Log in to reply
 

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