二叉树的递归遍历.md 去掉 Python 版本中无用的代码

This commit is contained in:
Lane Zhang
2024-10-23 10:07:56 +08:00
parent 42d84f8a7f
commit dcbd5b4674
2 changed files with 2 additions and 4 deletions

View File

@ -262,8 +262,6 @@ class Solution:
# 中序遍历-迭代-LC94_二叉树的中序遍历
class Solution:
def inorderTraversal(self, root: TreeNode) -> List[int]:
if not root:
return []
stack = [] # 不能提前将root结点加入stack中
result = []
cur = root
@ -280,7 +278,7 @@ class Solution:
cur = cur.right
return result
```
```python
```python
# 后序遍历-迭代-LC145_二叉树的后序遍历
class Solution:

View File

@ -107,7 +107,7 @@ cd a/b/c/../../
设计单调队列的时候pop和push操作要保持如下规则
1. pop(value)如果窗口移除的元素value等于单调队列的出口元素那么队列弹出元素否则不用任何操作
2. push(value)如果push的元素value大于入口元素的数值那么就将队列口的元素弹出直到push元素的数值小于等于队列入口元素的数值为止
2. push(value)如果push的元素value大于入口元素的数值那么就将队列口的元素弹出直到push元素的数值小于等于队列入口元素的数值为止
保持如上规则每次窗口移动的时候只要问que.front()就可以返回当前窗口的最大值。