摘要: class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = Noneroot1 = TreeNode(1)root2 = TreeNode(2)root1.left = root2# 这道题也是递 阅读全文
posted @ 2020-06-15 21:12 月为暮 阅读(239) 评论(0) 推荐(0) 编辑
摘要: # Definition for a binary tree node.class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None# 这道题是用深搜加上剪枝的算法来做的。# 遍历每一层节 阅读全文
posted @ 2020-06-15 21:02 月为暮 阅读(226) 评论(0) 推荐(0) 编辑
摘要: class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None# 这道题就是用深搜算法来做的,只要找出一个和为sum的就可以class Solution: def hasPathSum(se 阅读全文
posted @ 2020-06-15 20:56 月为暮 阅读(195) 评论(0) 推荐(0) 编辑