题目:

class Solution {
public:
void traversal(TreeNode* cur){
if(cur==nullptr) return;
swap(cur->left,cur->right); //从上换到下面就完事了
traversal(cur->left);
traversal(cur->right);
}
TreeNode* mirrorTree(TreeNode* root) {
traversal(root);
return root;
}
};

posted on 2023-08-05 12:40  孜孜不倦fly  阅读(11)  评论(0)    收藏  举报