offer 二叉树的镜像

/**
public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {
    public void Mirror(TreeNode root) {
        getMirror(root);
    }
    
    public TreeNode getMirror(TreeNode root){
        if (root != null){
            TreeNode rightNode = root.right;
            root.right = getMirror(root.left);
            root.left = getMirror(rightNode);
        }
        return root;
    }
}

 

posted @ 2020-04-21 10:34  lucy_cui  阅读(60)  评论(0)    收藏  举报