剑指 Offer 27. 二叉树的镜像

class Solution {
    public TreeNode mirrorTree(TreeNode root) {
        if(root == null) return null;
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;
        mirrorTree(root.left);
        mirrorTree(root.right);
        return root;
    }
}

 

posted @ 2020-08-10 17:52  欣姐姐  阅读(78)  评论(0编辑  收藏  举报