mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
Merge branch 'master' into binary_tree_iteration
This commit is contained in:
@@ -262,9 +262,11 @@ class Solution:
|
||||
# 中序遍历-迭代-LC94_二叉树的中序遍历
|
||||
class Solution:
|
||||
def inorderTraversal(self, root: TreeNode) -> List[int]:
|
||||
|
||||
if not root:
|
||||
return []
|
||||
stack = [] # 不能提前将root节点加入stack中
|
||||
|
||||
result = []
|
||||
cur = root
|
||||
while cur or stack:
|
||||
@@ -280,7 +282,7 @@ class Solution:
|
||||
cur = cur.right
|
||||
return result
|
||||
```
|
||||
```python
|
||||
```python
|
||||
|
||||
# 后序遍历-迭代-LC145_二叉树的后序遍历
|
||||
class Solution:
|
||||
|
||||
Reference in New Issue
Block a user