mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 11:34:46 +08:00
Update 0701.二叉搜索树中的插入操作.md
0701.二叉搜索树中的插入操作.md Python3 **递归法** - 无返回值 有注释 不用Helper function - 删掉无用变量 增加python标志
This commit is contained in:
@ -331,9 +331,8 @@ class Solution:
|
|||||||
```
|
```
|
||||||
|
|
||||||
**递归法** - 无返回值 有注释 不用Helper function
|
**递归法** - 无返回值 有注释 不用Helper function
|
||||||
```
|
```python
|
||||||
class Solution:
|
class Solution:
|
||||||
last = None
|
|
||||||
def insertIntoBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
|
def insertIntoBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
|
||||||
if not root: # for root==None
|
if not root: # for root==None
|
||||||
return TreeNode(val)
|
return TreeNode(val)
|
||||||
|
Reference in New Issue
Block a user