Python solution easy and understandable


#1

class Solution:
# @param A : root node of tree
# @return an integer
def sumNumbers(self, A):
def findpath(root,value):
if root is None:
return 0
value = (value*10+root.val)

        if root.left is None and root.right is None:
            return value
        return(findpath(root.left,value)+findpath(root.right,value))
        
    return findpath(A,0)%1003