
// 翻转二叉树
func invertTree(root *TreeNode) *TreeNode {
// 递归终止条件
if root == nil {
return nil
}
// 递归过程
root.Left, root.Right = root.Right, root.Left
root.Left = invertTree(root.Left)
root.Right = invertTree(root.Right)
return root
}

提交leetcode,通过
网友评论