Description
Submission
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* convertBST(TreeNode* root) { if(root == NULL) return NULL; convertBST(root->right); root->val += num; num = root->val; convertBST(root->left); return root; } private: int num = 0; };