解法
解法很简单 只要root的左子树 等于 root的右子树,root的右子树 等于左子树就行了 ,用临时结点记录一下就ok
代码
/**
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) {
if(root != null ){
TreeNode right = root.right;
TreeNode left = root.left;
root.left = right;
root.right = left;
Mirror(root.left);
Mirror(root.right);
}
}
} 
京公网安备 11010502036488号