题目描述
操作给定的二叉树,将其变换为源二叉树的镜像。
class Solution {
public:
void Mirror(TreeNode *pRoot) {
if(pRoot == NULL)
return;
if(pRoot->left==NULL&&pRoot->right==NULL)
return;
TreeNode* p = pRoot->left;
pRoot->left = pRoot->right;
pRoot->right = p;
if(pRoot->left)
Mirror(pRoot->left);
if(pRoot->right)
Mirror(pRoot->right);
}
};