Created
March 19, 2019 00:06
-
-
Save JasonGideon/1667faf09154a35ae0fd7deae6da8646 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: | |
print('check')<----print 了两次,说明第一次并没有 return True 出 method | |
return True <----请问这里为什么 return 不出去? | |
groupint.pop() | |
else: | |
findpath(root.left,groupint) | |
findpath(root.right,groupint) | |
groupint.pop() | |
return findpath(root,groupint) <----返回的是 NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment