mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 20:40:39 +08:00
Merge branch 'master' of https://github.com/csresource04/leetcode-master
This commit is contained in:
@ -271,6 +271,20 @@ class Solution:
|
|||||||
|
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
```Go
|
||||||
|
func insertIntoBST(root *TreeNode, val int) *TreeNode {
|
||||||
|
if root == nil {
|
||||||
|
root = &TreeNode{Val: val}
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
if root.Val > val {
|
||||||
|
root.Left = insertIntoBST(root.Left, val)
|
||||||
|
} else {
|
||||||
|
root.Right = insertIntoBST(root.Right, val)
|
||||||
|
}
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user