题目 :
把binary search tree
变成Greater Sum Tree
反正就是在二元搜寻树
对每个数字 把比他大的东西加起来
思路 :
好麻烦喔
重点就是你怎么遍历这棵树
反正就是先往右找到底
然后按照顺序找 先右再左
这样一定会是从大到小
然后把数字丢进全域变量
再弄回去
就写完了
可以打手枪了
好想打手枪
```cpp
class Solution {
public:
int all ;
void go(TreeNode* root)
{
if(root==NULL)return;
go(root->right);
all += root->val;
root->val = all;
go(root->left);
return;
}
TreeNode* bstToGst(TreeNode* root)
{
all = 0;
go(root);
return root;
}
};
```