Created
June 20, 2018 14:48
-
-
Save Kishy-nivas/c291174c55393caff5bf888e2078b5e7 to your computer and use it in GitHub Desktop.
greater_tree.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment