Update solution 0700

This commit is contained in:
halfrost
2021-11-26 05:21:49 -08:00
committed by halfrost
parent a7ce19c62e
commit 8ff3546b5d
2 changed files with 33 additions and 11 deletions

View File

@ -1,10 +1,20 @@
package leetcode package leetcode
type TreeNode struct { import (
Val int "github.com/halfrost/LeetCode-Go/structures"
Left *TreeNode )
Right *TreeNode
} // TreeNode define
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func searchBST(root *TreeNode, val int) *TreeNode { func searchBST(root *TreeNode, val int) *TreeNode {
if root == nil { if root == nil {

View File

@ -1,4 +1,4 @@
# [700. Search in a Binary Search Tree](https://leetcode-cn.com/problems/search-in-a-binary-search-tree/) # [700. Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree/)
## 题目 ## 题目
@ -38,13 +38,24 @@ Find the node in the BST that the node's value equals val and return the subtree
## 代码 ## 代码
```go ```go
package leetcode package leetcode
type TreeNode struct { import (
Val int "github.com/halfrost/LeetCode-Go/structures"
Left *TreeNode )
Right *TreeNode
} // TreeNode define
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func searchBST(root *TreeNode, val int) *TreeNode { func searchBST(root *TreeNode, val int) *TreeNode {
if root == nil { if root == nil {
@ -58,4 +69,5 @@ func searchBST(root *TreeNode, val int) *TreeNode {
return searchBST(root.Left, val) return searchBST(root.Left, val)
} }
} }
``` ```