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 7692d6c

Browse files
committed
Update 0669.修剪二叉搜索树,添加C#
1 parent 35322cb commit 7692d6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎problems/0669.修剪二叉搜索树.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,23 @@ impl Solution {
567567
}
568568
}
569569
```
570+
### C#
571+
```C#
572+
// 递归
573+
public TreeNode TrimBST(TreeNode root, int low, int high)
574+
{
575+
if (root == null) return null;
576+
if (root.val < low)
577+
return TrimBST(root.right, low, high);
578+
579+
if (root.val > high)
580+
return TrimBST(root.left, low, high);
581+
582+
root.left = TrimBST(root.left, low, high);
583+
root.right = TrimBST(root.right, low, high);
584+
return root;
585+
}
586+
```
570587

571588

572589
<p align="center">

0 commit comments

Comments
(0)

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