class Solution:
def FindPath(self, root, expectNumber):
if root ==None:
return []
elif root.left == None and root.right == None and root.val == expectNumber:
return [[root.val]]
res=[]
left=self.FindPath(root.left, expectNumber-root.val)
right=self.FindPath(root.right, expectNumber-root.val)
for item in left+right:
res.append([root.val]+item)
return res
网友评论