dfs 要点是这一句: return node.val==1 or node.left or node.right 完整代码: # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None import functools class Solution: @functools.lru_cach…