c++ clear and fast


  • 0
    9
    class Solution {
    public:
        TreeNode* convertBST(TreeNode* root) {
            Inorder(root);
            return root;
        }
        int Inorder(TreeNode* root,int sum=0)   
        {
            if(!root)   return sum;
            else
            {
                sum=Inorder(root->right,sum);
                return  sum=Inorder(root->left,root->val+=sum);
            }
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.