Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int sum =0;
- TreeNode* convertBST(TreeNode* root) {
- if(root == nullptr)
- return nullptr;
- convertBST(root->right);
- sum += root->val;
- root->val = sum ;
- convertBST(root->left);
- return root;
- }
- };
Add Comment
Please, Sign In to add comment