2-liner C++ with global sum and reverse In-order Traversal


  • 0
        int sum = 0;
        
        TreeNode* convertBST(TreeNode* r) {
            if (r) convertBST(r->right), sum = r->val += sum, convertBST(r->left);
            return r;
        }
    

Log in to reply
 

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