Update0701.二叉搜索树中的插入操作,添加C#

This commit is contained in:
eeee0717
2023-12-06 09:05:08 +08:00
parent 09e230bef3
commit 35322cb120

View File

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