class Solution {
public int sum = 0;
public TreeNode convertBST(TreeNode root) {
if(root == null){
return null;
[450](https://leetcode.cn/problems/delete-node-in-a-bst/)、删除二叉搜索树中的节点
![](https://img2023.cnblogs.com/blog/3018498/202212/3018498-20221204165910667-1246243087.png)
convertBST(root.right);
root.val += sum;
sum = root.val;
convertBST(root.left);