add: leetcode 0700 solution

This commit is contained in:
tphyhFighting
2021-11-26 11:18:00 +08:00
parent f0792d1179
commit 6ecc8bf8e7

View File

@ -0,0 +1,20 @@
package leetcode
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func searchBST(root *TreeNode, val int) *TreeNode {
if root == nil {
return nil
}
if root.Val == val {
return root
} else if root.Val < val {
return searchBST(root.Right, val)
} else {
return searchBST(root.Left, val)
}
}