Update 0669.修剪二叉搜索树,添加C#

This commit is contained in:
eeee0717
2023-12-08 08:08:10 +08:00
parent 35322cb120
commit 7692d6cc97

View File

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