1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// @Title: 二叉树的镜像 (二叉树的镜像  LCOF)
// @Author: 15816537946@163.com
// @Date: 2022-02-12 11:08:47
// @Runtime: 0 ms
// @Memory: 2 MB
/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
func mirrorTree(root *TreeNode) *TreeNode {
    if root == nil {
        return root
    }
    root.Left, root.Right = mirrorTree(root.Right),mirrorTree(root.Left)
    return root
}