Short python solution

  • 2
    class Solution(object):
    def sumNumbers(self, root):
        if not root: return 0
        self.res=0, '')
        return self.res
    def cal(self, root, temp):
        if not root: return
        if not root.left and not root.right: self.res+=int(temp+str(root.val))
        for node in [root.left, root.right]:, temp+str(root.val))

  • 0
    This post is deleted!

Log in to reply

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