题解 | #二叉树的镜像#
二叉树的镜像
http://www.nowcoder.com/practice/a9d0ecbacef9410ca97463e4a5c83be7
public class Solution {
public TreeNode Mirror (TreeNode pRoot) {
if(pRoot!=null){
TreeNode tempNode = pRoot.left;
pRoot.left = pRoot.right;
pRoot.right = tempNode;
Mirror(pRoot.left);
Mirror(pRoot.right);
}
return pRoot;
}
}
public TreeNode Mirror (TreeNode pRoot) {
if(pRoot!=null){
TreeNode tempNode = pRoot.left;
pRoot.left = pRoot.right;
pRoot.right = tempNode;
Mirror(pRoot.left);
Mirror(pRoot.right);
}
return pRoot;
}
}