mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 20:40:39 +08:00
Update 0700.二叉搜索树中的搜索.md
This commit is contained in:
@ -230,7 +230,7 @@ class Solution {
|
||||
|
||||
### Python
|
||||
|
||||
递归法:
|
||||
(方法一) 递归
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
@ -250,12 +250,12 @@ class Solution:
|
||||
|
||||
```
|
||||
|
||||
迭代法:
|
||||
(方法二)迭代
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
def searchBST(self, root: TreeNode, val: int) -> TreeNode:
|
||||
while root is not None:
|
||||
while root:
|
||||
if val < root.val: root = root.left
|
||||
elif val > root.val: root = root.right
|
||||
else: return root
|
||||
|
Reference in New Issue
Block a user