自己的题解:
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public TreeNode mirrorTree(TreeNode root) {
swap(root);
return root;
}
public void swap(TreeNode root){
if(root == null) return ;
TreeNode left = root.left;
root.left = root.right;
root.right = left;
swap(root.left);
swap(root.right);
}
}