113. Path Sum II
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:def pathSum(self, root: Optional[TreeNode], targetSum: int) -> List[List[int]]:path=[]def findpath(root,history,target):if not root: return if root.left==None and root.right==None:if root.val==target:path.append(history+[root.val])if root.left:findpath(root.left,history+[root.val],target-root.val)if root.right:findpath(root.right,history+[root.val],target-root.val)findpath(root,[],targetSum)return path