```
TreeNode* convertBST(TreeNode* root) {
int sum=0;
DFS(root, sum);
return root;
}
void DFS(TreeNode*& r, int& sum){
if(r==NULL) return;
DFS(r->right, sum);
sum+=r->val;
r->val=sum;
DFS(r->left, sum);
}
```