class Solution {

public:

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

};