mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
update 0700.二叉搜索树中的搜索: 修改 go 的迭代法
This commit is contained in:
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
## 思路
|
## 思路
|
||||||
|
|
||||||
之前我们讲了都是普通二叉树,那么接下来看看二叉搜索树。
|
之前我们讲的都是普通二叉树,那么接下来看看二叉搜索树。
|
||||||
|
|
||||||
在[关于二叉树,你该了解这些!](https://programmercarl.com/二叉树理论基础.html)中,我们已经讲过了二叉搜索树。
|
在[关于二叉树,你该了解这些!](https://programmercarl.com/二叉树理论基础.html)中,我们已经讲过了二叉搜索树。
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ func searchBST(root *TreeNode, val int) *TreeNode {
|
|||||||
} else if root.Val < val {
|
} else if root.Val < val {
|
||||||
root = root.Right
|
root = root.Right
|
||||||
} else {
|
} else {
|
||||||
break
|
return root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user