/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
struct TreeNode* Treserve(struct TreeNode* root)
{
if(!root) return NULL;
struct TreeNode* preserve = root->right;
root->right = Treserve(root->left);
root->left = Treserve(preserve);
return root;
}
struct TreeNode* invertTree(struct TreeNode* root){
root = Treserve(root);
return root;
}
翻转二叉树(leetcode)
最新推荐文章于 2022-02-26 22:34:53 发布