leetcode971】的更多相关文章

Given a binary tree with N nodes, each node has a different value from {1, ..., N}. A node in this binary tree can be flipped by swapping the left child and the right child of that node. Consider the sequence of N values reported by a preorder traver…
class Solution: def flipMatchVoyage(self, root, voyage): res = [] self.i = 0 def dfs(root): if not root: return True if root.val != voyage[self.i]: return False self.i += 1 if root.left and root.left.val != voyage[self.i]: res.append(root.val) root.l…