def invertBinaryTree(self, root):
# 递归
self.dfs(root)
def dfs(self, node):
if node == None:
return
left = node.left
right = node.right
node.left = right
node.right = left
self.dfs(left)
self.dfs(right)
网友评论