update538.把二叉搜索树转换为累加树,添加C#

This commit is contained in:
eeee0717
2023-12-10 09:25:18 +08:00
parent 0e55c1b424
commit e59dbae465

View File

@ -529,6 +529,23 @@ impl Solution {
}
}
```
### C#
```C#
// 递归
public class Solution
{
int pre = 0;
public TreeNode ConvertBST(TreeNode root)
{
if (root == null) return null;
ConvertBST(root.right);
root.val += pre;
pre = root.val;
ConvertBST(root.left);
return root;
}
}
```
<p align="center">