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 35322cb

Browse files
committed
Update0701.二叉搜索树中的插入操作,添加C#
1 parent 09e230b commit 35322cb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎problems/0701.二叉搜索树中的插入操作.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,17 @@ impl Solution {
691691
}
692692
}
693693
```
694+
### C#
695+
``` C#
696+
// 递归
697+
public TreeNode InsertIntoBST(TreeNode root, int val) {
698+
if (root == null) return new TreeNode(val);
699+
700+
if (root.val > val) root.left = InsertIntoBST(root.left, val);
701+
if (root.val < val) root.right = InsertIntoBST(root.right, val);
702+
return root;
703+
}
704+
```
694705

695706

696707
<p align="center">

0 commit comments

Comments
(0)

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