Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 19 additions & 8 deletions content/chapter-02-stack-queue/00-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,37 @@ status: "draft"
1. 先学习[栈](./01-stack.md),建立“后进先出 + 表尾操作”的模型,再完成[Lab 02-T-01:栈选择题精练](../../labs/chapter-02/theory/T-02-01-stack-quiz/README.md)检查基础概念。
2. 再学习[队列](./02-queue.md),重点理解循环队列判空判满的边界约定,再完成[Lab 02-T-02:队列选择题精练](../../labs/chapter-02/theory/T-02-02-queue-quiz/README.md)检查公式应用与实现取舍。
3. 完成基础实现练习:先做栈序列与最小栈,再做队列窗口、循环结构和用栈实现队列。
4. 接着学习[应用](./03-applications.md),完成其中的逆波兰表达式求值例题,并用 Lab 02-E-07 与 02-E-08 练习单调队列、单调栈与边界计算。
5. 完成[Lab 02-T-03:栈与队列综合理论题](../../labs/chapter-02/theory/T-02-03-stack-queue-comprehensive/README.md),用 20 道选择题和 5 道理论大题检查序列约束、结构设计与证明。
6. 最后依次完成可撤销浏览器、超市收银模拟与停车场管理三个综合 Lab。
1. 先学习[栈](./01-stack.md),建立“后进先出 + 表尾操作”的模型,再完成[Lab 02-T-01:栈选择题精练](../../labs/chapter-02/theory/T-02-01-stack-quiz/README.md)检查基础概念。
2. 再学习[队列](./02-queue.md),重点理解循环队列判空判满的边界约定,再完成[Lab 02-T-02:队列选择题精练](../../labs/chapter-02/theory/T-02-02-queue-quiz/README.md)检查公式应用与实现取舍。
3. 完成基础实现练习:先做栈序列与最小栈,再做队列窗口、循环结构和用栈实现队列。
4. 接着学习[应用](./03-applications.md),完成逆波兰表达式求值、中缀转后缀、单调栈与逐层扩散练习。
5. 最后依次完成可撤销浏览器、超市收银模拟与停车场管理三个综合 Lab。

## 配套 Labs

| 实践主题 | 对应 Lab | 验收重点 |
| --- | --- | --- |
| 栈的概念、边界与复杂度 | [Lab 02-T-01:栈选择题精练](../../labs/chapter-02/theory/T-02-01-stack-quiz/README.md) | 独立判断出栈序列、空满条件、括号匹配与基本操作复杂度 |
| 队列的语义、边界与实现取舍 | [Lab 02-T-02:队列选择题精练](../../labs/chapter-02/theory/T-02-02-queue-quiz/README.md) | 推导循环下标与长度,辨析链队列边界、复杂度和工程选型 |
| 栈与队列综合理论 | [Lab 02-T-03:栈与队列综合理论题](../../labs/chapter-02/theory/T-02-03-stack-queue-comprehensive/README.md) | 20 道选择题与 5 道大题,完成约束分析、空间复用设计和序列计数证明 |
| 栈的模拟与接口实现 | [Lab 02-E-01:验证栈序列](../../labs/chapter-02/exercise/E-02-01-validate-stack-sequences/README.md)、[Lab 02-E-02:最小栈](../../labs/chapter-02/exercise/E-02-02-min-stack/README.md) | 从基础模拟推进到常数时间辅助状态维护 |
| 队列的窗口与接口实现 | [Lab 02-E-03:最近请求](../../labs/chapter-02/exercise/E-02-03-recent-counter/README.md)、[Lab 02-E-04:循环队列](../../labs/chapter-02/exercise/E-02-04-circular-queue/README.md)、[Lab 02-E-05:用栈实现队列](../../labs/chapter-02/exercise/E-02-05-queue-using-stacks/README.md)、[Lab 02-E-06:循环双端队列](../../labs/chapter-02/exercise/E-02-06-circular-deque/README.md) | 掌握滑动窗口、环绕下标、摊还分析和两端操作 |
| 单调结构进阶 | [Lab 02-E-07:滑动窗口最大值](../../labs/chapter-02/exercise/E-02-07-sliding-window-maximum/README.md)、[Lab 02-E-08:柱状图最大矩形](../../labs/chapter-02/exercise/E-02-08-largest-rectangle-histogram/README.md) | 维护候选单调性,处理窗口过期和左右边界 |
| 实践主题 | 对应 Lab | 验收重点 |
| --- | --- | --- |
| 栈的概念、边界与复杂度 | [Lab 02-T-01:栈选择题精练](../../labs/chapter-02/theory/T-02-01-stack-quiz/README.md) | 独立判断出栈序列、空满条件、括号匹配与基本操作复杂度 |
| 队列的语义、边界与实现取舍 | [Lab 02-T-02:队列选择题精练](../../labs/chapter-02/theory/T-02-02-queue-quiz/README.md) | 推导循环下标与长度,辨析链队列边界、复杂度和工程选型 |
| 栈的模拟与接口实现 | [02-03 验证栈序列](../../labs/chapter-02/exercise/E-02-01-validate-stack-sequences/README.md)、[02-04 最小栈](../../labs/chapter-02/exercise/E-02-02-min-stack/README.md) | 从基础模拟推进到常数时间辅助状态维护 |
| 队列的窗口与接口实现 | [02-05 最近请求](../../labs/chapter-02/exercise/E-02-03-recent-counter/README.md)、[02-06 循环队列](../../labs/chapter-02/exercise/E-02-04-circular-queue/README.md)、[02-07 用栈实现队列](../../labs/chapter-02/exercise/E-02-05-queue-using-stacks/README.md)、[02-08 循环双端队列](../../labs/chapter-02/exercise/E-02-06-circular-deque/README.md) | 掌握滑动窗口、环绕下标、摊还分析和两端操作 |
| 单调结构进阶 | [02-09 滑动窗口最大值](../../labs/chapter-02/exercise/E-02-07-sliding-window-maximum/README.md)、[02-10 柱状图最大矩形](../../labs/chapter-02/exercise/E-02-08-largest-rectangle-histogram/README.md) | 维护候选单调性,处理窗口过期和左右边界 |
| 表达式与匹配 | [Lab 02-E-09:括号匹配](../../labs/chapter-02/exercise/E-02-09-bracket-matching/README.md)、[Lab 02-E-10:逆波兰表达式求值](../../labs/chapter-02/exercise/E-02-10-rpn-evaluation/README.md)、[Lab 02-E-11:中缀表达式转后缀](../../labs/chapter-02/exercise/E-02-11-infix-to-postfix/README.md) | 检验嵌套匹配、操作数顺序、优先级和括号边界 |
| 单调栈与逐层扩散 | [Lab 02-E-12:下一个更大元素](../../labs/chapter-02/exercise/E-02-12-next-greater-element/README.md)、[Lab 02-E-13:下一个更小元素](../../labs/chapter-02/exercise/E-02-13-next-smaller-element/README.md)、[Lab 02-E-14:农夫抓牛](../../labs/chapter-02/exercise/E-02-14-farmer-cow-bfs/README.md)、[Lab 02-E-20:股票价格跨度](../../labs/chapter-02/exercise/E-02-20-stock-span/README.md) | 维护单调候选,并用 FIFO 保证按层最短路径 |
| 队列与栈应用 | [Lab 02-E-15:Josephus 出列顺序](../../labs/chapter-02/exercise/E-02-15-josephus-order/README.md)、[Lab 02-E-16:队列生成二进制数](../../labs/chapter-02/exercise/E-02-16-binary-number-queue/README.md)、[Lab 02-E-17:双端队列回文检查](../../labs/chapter-02/exercise/E-02-17-palindrome-deque/README.md)、[Lab 02-E-18:反转队列前 K 个元素](../../labs/chapter-02/exercise/E-02-18-reverse-first-k-queue/README.md)、[Lab 02-E-19:仅用辅助栈排序](../../labs/chapter-02/exercise/E-02-19-stack-sorting/README.md) | 练习循环调度、FIFO 生成、双端访问和辅助结构协作 |
| 栈、导航历史与 Undo/Redo | [Lab 02-P-01:可撤销浏览器](../../labs/chapter-02/project/P-02-01-undoable-browser/README.md) | 用完整页面状态协调后退、前进和页面级命令历史 |
| FIFO、多队列与离散时间 | [Lab 02-P-02:超市收银模拟](../../labs/chapter-02/project/P-02-02-supermarket-checkout/README.md) | 统一时间口径,验证等待、逗留、忙碌率和队列峰值 |
| 栈与队列联动 | [Lab 02-P-03:停车场管理](../../labs/chapter-02/project/P-02-03-parking-lot-management/README.md) | 完成倒车、便道补位、中间删除与统计 |
| 栈、导航历史与 Undo/Redo | [Lab 02-P-01:可撤销浏览器](../../labs/chapter-02/project/P-02-01-undoable-browser/README.md) | 用完整页面状态协调后退、前进和页面级命令历史 |
| FIFO、多队列与离散时间 | [Lab 02-P-02:超市收银模拟](../../labs/chapter-02/project/P-02-02-supermarket-checkout/README.md) | 统一时间口径,验证等待、逗留、忙碌率和队列峰值 |
| 栈与队列联动 | [Lab 02-P-03:停车场管理](../../labs/chapter-02/project/P-02-03-parking-lot-management/README.md) | 完成倒车、便道补位、中间删除与统计 |

::: info Lab 编号说明
Lab 02-T-01 与 Lab 02-T-02 是交互式概念自测,Lab 02-T-03 是包含理论大题的综合训练;Lab 02-E-01 至 Lab 02-E-08 是带起始代码、参考实现和 100 分自动测试的 Program Lab;Lab 02-P-01 至 Lab 02-P-03 是综合 Project 规格,目前仍需学习者按任务说明自行创建实现。侧栏按 Theory、Exercise、Project 分类展示。
Lab 02-01 与 Lab 02-02 是交互式概念自测;20 道 Exercise 均带起始代码、参考实现和 100 分自动测试;3 道 Project 用于综合建模。侧栏按 Theory、Exercise、Project 分类展示。
:::

## 学习建议
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "001-valid-sample",
"input": "tests/001-valid-sample.in",
"expected": "tests/001-valid-sample.out",
"points": 10,
"points": 8,
"tags": [
"sample"
],
Expand All @@ -15,7 +15,7 @@
"id": "002-invalid-middle",
"input": "tests/002-invalid-middle.in",
"expected": "tests/002-invalid-middle.out",
"points": 20,
"points": 8,
"tags": [
"normal"
]
Expand All @@ -24,7 +24,7 @@
"id": "003-invalid-after-first",
"input": "tests/003-invalid-after-first.in",
"expected": "tests/003-invalid-after-first.out",
"points": 15,
"points": 8,
"tags": [
"regression"
]
Expand All @@ -33,7 +33,7 @@
"id": "004-single",
"input": "tests/004-single.in",
"expected": "tests/004-single.out",
"points": 15,
"points": 8,
"tags": [
"boundary",
"numeric-boundary"
Expand All @@ -43,7 +43,7 @@
"id": "005-empty",
"input": "tests/005-empty.in",
"expected": "tests/005-empty.out",
"points": 10,
"points": 8,
"tags": [
"boundary"
]
Expand All @@ -52,7 +52,7 @@
"id": "006-all-delayed",
"input": "tests/006-all-delayed.in",
"expected": "tests/006-all-delayed.out",
"points": 10,
"points": 4,
"tags": [
"normal"
]
Expand All @@ -61,28 +61,127 @@
"id": "007-scale",
"input": "tests/007-scale.in",
"expected": "tests/007-scale.out",
"points": 2,
"points": 4,
"tags": [
"scale",
"complexity"
]
},
{"id":"008-interleaved-valid","input":"tests/008-interleaved-valid.in","expected":"tests/008-interleaved-valid.out","points":1,"tags":["normal"]},
{"id":"009-invalid-late","input":"tests/009-invalid-late.in","expected":"tests/009-invalid-late.out","points":1,"tags":["regression"]},
{"id":"010-immediate-valid","input":"tests/010-immediate-valid.in","expected":"tests/010-immediate-valid.out","points":1,"tags":["normal"]},
{"id":"011-negative-reverse","input":"tests/011-negative-reverse.in","expected":"tests/011-negative-reverse.out","points":1,"tags":["normal"]},
{"id":"012-small-invalid","input":"tests/012-small-invalid.in","expected":"tests/012-small-invalid.out","points":1,"tags":["boundary"]},
{"id":"013-delayed-valid","input":"tests/013-delayed-valid.in","expected":"tests/013-delayed-valid.out","points":1,"tags":["normal"]},
{"id":"014-int64-values","input":"tests/014-int64-values.in","expected":"tests/014-int64-values.out","points":1,"tags":["boundary"]},
{"id":"015-alternating-valid","input":"tests/015-alternating-valid.in","expected":"tests/015-alternating-valid.out","points":1,"tags":["normal"]},
{"id":"016-two-valid-blocks","input":"tests/016-two-valid-blocks.in","expected":"tests/016-two-valid-blocks.out","points":1,"tags":["normal"]},
{"id":"017-invalid-after-prefix","input":"tests/017-invalid-after-prefix.in","expected":"tests/017-invalid-after-prefix.out","points":1,"tags":["regression"]},
{"id":"018-alternating-valid","input":"tests/018-alternating-valid.in","expected":"tests/018-alternating-valid.out","points":1,"tags":["normal"]},
{"id":"019-extreme-values","input":"tests/019-extreme-values.in","expected":"tests/019-extreme-values.out","points":1,"tags":["boundary"]},
{"id":"020-invalid-stack-top","input":"tests/020-invalid-stack-top.in","expected":"tests/020-invalid-stack-top.out","points":1,"tags":["regression"]},
{"id":"021-blockwise-valid","input":"tests/021-blockwise-valid.in","expected":"tests/021-blockwise-valid.out","points":1,"tags":["normal"]},
{"id":"022-invalid-late-top","input":"tests/022-invalid-late-top.in","expected":"tests/022-invalid-late-top.out","points":1,"tags":["regression"]},
{"id":"023-negative-valid","input":"tests/023-negative-valid.in","expected":"tests/023-negative-valid.out","points":1,"tags":["normal"]},
{"id":"024-three-blocks","input":"tests/024-three-blocks.in","expected":"tests/024-three-blocks.out","points":1,"tags":["normal"]},
{"id":"025-invalid-final-block","input":"tests/025-invalid-final-block.in","expected":"tests/025-invalid-final-block.out","points":1,"tags":["regression"]}
{
"id": "008-interleaved-valid",
"input": "tests/008-interleaved-valid.in",
"expected": "tests/008-interleaved-valid.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "009-invalid-late",
"input": "tests/009-invalid-late.in",
"expected": "tests/009-invalid-late.out",
"points": 4,
"tags": [
"regression"
]
},
{
"id": "010-immediate-valid",
"input": "tests/010-immediate-valid.in",
"expected": "tests/010-immediate-valid.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "011-negative-reverse",
"input": "tests/011-negative-reverse.in",
"expected": "tests/011-negative-reverse.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "012-small-invalid",
"input": "tests/012-small-invalid.in",
"expected": "tests/012-small-invalid.out",
"points": 4,
"tags": [
"boundary"
]
},
{
"id": "013-delayed-valid",
"input": "tests/013-delayed-valid.in",
"expected": "tests/013-delayed-valid.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "014-int64-values",
"input": "tests/014-int64-values.in",
"expected": "tests/014-int64-values.out",
"points": 4,
"tags": [
"boundary"
]
},
{
"id": "015-alternating-valid",
"input": "tests/015-alternating-valid.in",
"expected": "tests/015-alternating-valid.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "016-two-valid-blocks",
"input": "tests/016-two-valid-blocks.in",
"expected": "tests/016-two-valid-blocks.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "017-invalid-after-prefix",
"input": "tests/017-invalid-after-prefix.in",
"expected": "tests/017-invalid-after-prefix.out",
"points": 4,
"tags": [
"regression"
]
},
{
"id": "018-alternating-valid",
"input": "tests/018-alternating-valid.in",
"expected": "tests/018-alternating-valid.out",
"points": 4,
"tags": [
"normal"
]
},
{
"id": "019-extreme-values",
"input": "tests/019-extreme-values.in",
"expected": "tests/019-extreme-values.out",
"points": 4,
"tags": [
"boundary"
]
},
{
"id": "020-invalid-stack-top",
"input": "tests/020-invalid-stack-top.in",
"expected": "tests/020-invalid-stack-top.out",
"points": 4,
"tags": [
"regression"
]
}
]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading