Created
March 19, 2019 00:05
-
-
Save JasonGideon/9c1a498cf53f4bff891de2aa465fd86f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def hasPathSum(self, root: TreeNode, suma: int) -> bool: | |
def findpath(root,groupint): | |
if root: | |
groupint.append(root.val) | |
if not root.right and not root.left: | |
if sum(groupint) == suma: | |
self.res = True | |
groupint.pop() | |
else: | |
findpath(root.left,groupint) | |
findpath(root.right,groupint) | |
groupint.pop() | |
self.res = False | |
findpath(root,[]) | |
return self.res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment