python, recursive
helper: return the path starts from the root and has path sum = target. \n\nThe paths that have path_sum = target can only be \n1. Paths start from root;\n2. Pa
helper: return the path starts from the root and has path sum = target. \n\nThe paths that have path_sum = target can only be \n1. Paths start from root;\n2. Paths inside the left subtree of root;\n3. Paths inside the right subtree of root;\n\n\n```\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def pathSum(self, root: TreeNode, sum: int) -> int:\n        if root:\n            c = self.helper(root, sum) # start from the root\n            l = self.pathSum(root.left, sum) # inside the left subtree\n            r = self.pathSum(root.right, sum) # inside the right subtree\n            return c + l + r\n        return 0 \n        \n    def helper(self, root, sum): \n        if root:\n            l = self.helper(root.left, sum - root.val)\n            r = self.helper(root.right, sum - root.val)\n            return l + r  +  (root.val == sum)\n        return 0 \n          \n\n```
['Python']