每日刷题 day 08 ---二叉树的镜像

81 阅读1分钟

leetcode传送门

image.png 思路:简单题,其实就是将左右子节点交换,然后分别递归左右节点即可

    function MirrorTree(root){
        if(!root) {
            return null
        }
        [root.left,root.right] = [root.right,root.left]
        MirrorTree(root.left)
        MirrorTree(root.right)
        return root
    }