Merge branch 'master' into binary_tree_iteration

This commit is contained in:
程序员Carl
2024-12-05 10:04:10 +08:00
committed by GitHub
128 changed files with 2084 additions and 542 deletions

View File

@@ -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: