leetcode 226. Invert Binary Tree

    TreeNode* invertTree(TreeNode* root) {
        if (root == NULL) return NULL;
        
        auto temp = root->left;
        root->left = root->right;
        root->right = temp;
        invertTree(root->left);
        invertTree(root->right);
        return root;
    }

 

posted on 2018-02-06 11:27  willaty  阅读(78)  评论(0编辑  收藏  举报

导航