diff --git a/problems/二叉树的迭代遍历.md b/problems/二叉树的迭代遍历.md index 5f59c388..ba63d06b 100644 --- a/problems/二叉树的迭代遍历.md +++ b/problems/二叉树的迭代遍历.md @@ -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: diff --git a/problems/栈与队列总结.md b/problems/栈与队列总结.md index 113f4a06..df022c77 100644 --- a/problems/栈与队列总结.md +++ b/problems/栈与队列总结.md @@ -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()就可以返回当前窗口的最大值。