/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */

public class Solution {

    private int sum = 0;

    public TreeNode convertBST(TreeNode root) {

        if (root == null) {
            return null;
        }

        convertBST(root.right);

        root.val += sum;
        sum = root.val;

        convertBST(root.left);

        return root;

    }

}

Create : 538 Convert BST to Greater Tree
Create : 538 Convert BST to Greater Tree
