1
class Solution(object):
2
def hasPathSum(self, root, targetSum):
3
"""
4
:type root: TreeNode
5
:type targetSum: int
6
:rtype: bool
7
"""
8
if not root:
9
return False
10
targetSum -= root.val
11
if not root.left and not root.right:
12
return not targetSum
13
return self.hasPathSum(root.left, targetSum) or self.hasPathSum(
14
root.right, targetSum
15
)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0