/* f():将树镜像翻转返回指针 递归出口:当pRoot==NULL return NULL;return pRoot; 左右子树翻转f(pRoot->left);f(pRoot->right) tmp=pRoot->right;保存一个子树的指针交换时防止被覆盖 pRoot->right = f(pRoot->left); pRoot->left = f(pRoot->right); */ class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * @param pRoot TreeNode类 * @return TreeNode类 */ TreeNode* Mirror(TreeNode* pRoot) { if(pRoot==NULL)return NULL; TreeNode* tmp=pRoot->right; pRoot->right = Mirror(pRoot->left); pRoot->left = Mirror(tmp); return pRoot; } };