From dcbd5b4674c763dd2e156318cee383a79861f954 Mon Sep 17 00:00:00 2001 From: Lane Zhang Date: Wed, 23 Oct 2024 10:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=E7=9A=84=E9=80=92?= =?UTF-8?q?=E5=BD=92=E9=81=8D=E5=8E=86.md=20=E5=8E=BB=E6=8E=89=20Python=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=AD=E6=97=A0=E7=94=A8=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/二叉树的迭代遍历.md | 4 +--- problems/栈与队列总结.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) 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()就可以返回当前窗口的最大值。