Update 0700.二叉搜索树中的搜索.md

This commit is contained in:
jianghongcheng 2023-05-09 18:50:14 -05:00 committed by GitHub
parent a45046be8a
commit 3818de4610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -230,7 +230,7 @@ class Solution {
### Python ### Python
递归法: (方法一) 递归
```python ```python
class Solution: class Solution:
@ -250,12 +250,12 @@ class Solution:
``` ```
迭代法: (方法二)迭代
```python ```python
class Solution: class Solution:
def searchBST(self, root: TreeNode, val: int) -> TreeNode: def searchBST(self, root: TreeNode, val: int) -> TreeNode:
while root is not None: while root:
if val < root.val: root = root.left if val < root.val: root = root.left
elif val > root.val: root = root.right elif val > root.val: root = root.right
else: return root else: return root