题目

var convertBST = function(root) {
    let num = 0;
    function bst(root){
        if (root != null) {
            //遍历右子树
            bst(root.right);
            //遍历顶点
            root.val = root.val + num;
            num = root.val;
            //遍历左子树
            bst(root.left);
        }
    }
    bst(root);
    return root;
};