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…