leetcode-剑指27-OK

language: C

address

// 很简单的递归
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

struct TreeNode* mirrorTree(struct TreeNode* root){
    struct TreeNode* temp;
    void inverse(struct TreeNode* one){
        if(one==NULL)
            return;
        temp = one->left;
        one->left = one->right;
        one->right = temp;
        inverse(one->left);
        inverse(one->right);
    }
    inverse(root);
    return root;
}
posted @ 2021-01-25 09:11  RougeBW  阅读(28)  评论(0编辑  收藏  举报