Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

二叉树的递归遍历.md 去掉 Python 版本中无用的代码;修复一处说明错误:队列出口的元素 改为 队列入口的元素. #2806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions problems/二叉树的迭代遍历.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -280,7 +278,7 @@ class Solution:
cur = cur.right
return result
```
```python
```python

# 后序遍历-迭代-LC145_二叉树的后序遍历
class Solution:
Expand Down
2 changes: 1 addition & 1 deletion problems/栈与队列总结.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ cd a/b/c/../../
设计单调队列的时候,pop,和push操作要保持如下规则:

1. pop(value):如果窗口移除的元素value等于单调队列的出口元素,那么队列弹出元素,否则不用任何操作
2. push(value):如果push的元素value大于入口元素的数值,那么就将队列出口的元素弹出,直到push元素的数值小于等于队列入口元素的数值为止
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

队列出口的元素 -> 队列入口的元素

2. push(value):如果push的元素value大于入口元素的数值,那么就将队列入口的元素弹出,直到push元素的数值小于等于队列入口元素的数值为止

保持如上规则,每次窗口移动的时候,只要问que.front()就可以返回当前窗口的最大值。

Expand Down