// 按照右中左的顺序递归遍历;在函数外定义全局变量sum
class Solution {
int sum = 0 ;
public TreeNode convertBST(TreeNode root) {
if(root == null) return root;
convertBST(root.right);
root.val = root.val + sum;
sum = root.val;
convertBST(root.left);
return root;
}
}