LCR 054. 把二叉搜索树转换为累加树 使用后序遍历即可 class Solution { public: TreeNode* convertBST(TreeNode* root) { int temp = 0; dfs(root,temp); return root; } void dfs(TreeNode* root,int &temp){ if(!root){ return ; } dfs(root->right,temp); temp += root->val; root->val = temp; dfs(root->left,temp); } };