Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e59dbae

Browse files
committed
update538.把二叉搜索树转换为累加树,添加C#
1 parent 0e55c1b commit e59dbae

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎problems/0538.把二叉搜索树转换为累加树.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,23 @@ impl Solution {
529529
}
530530
}
531531
```
532+
### C#
533+
```C#
534+
// 递归
535+
public class Solution
536+
{
537+
int pre = 0;
538+
public TreeNode ConvertBST(TreeNode root)
539+
{
540+
if (root == null) return null;
541+
ConvertBST(root.right);
542+
root.val += pre;
543+
pre = root.val;
544+
ConvertBST(root.left);
545+
return root;
546+
}
547+
}
548+
```
532549

533550

534551
<p align="center">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /