diff --git a/problems/0538.把二叉搜索树转换为累加树.md b/problems/0538.把二叉搜索树转换为累加树.md index c403c98f..07cae1ad 100644 --- a/problems/0538.把二叉搜索树转换为累加树.md +++ b/problems/0538.把二叉搜索树转换为累加树.md @@ -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; + } +} +```