Tonight's goal: pick your three weakest stack problems from the menu, re-solve each from a blank file with no hints, and keep the monotonic-stack invariant sharp.
Tonight's protocol
Use the revision-day protocol: blank file, no hints, and only run one or run two can count.
0:00–0:04: answer the warm-up MCQs in one pass. Do not study explanations yet.
0:04–0:05: pick your three weakest problems from the menu. Choose the three you least want to face tonight.
0:05–0:25: problem 1. Say the pattern name, invariant, brute force, and target complexity before coding.
0:25–0:45: problem 2. Open a fresh blank file; no notes, hints, stored code, or videos.
0:45–1:05: problem 3. Stop judging after the second run, even if you continue debugging.
1:05–1:15: compare only failed or shaky attempts. Write WA: <root cause> for each miss.
The problem menu
Pick your three weakest from this menu, re-solve from a blank file, no hints.
Lesson 16's invariant: “A stack remembers the most recent unresolved opener — exactly what bracket nesting needs; a shadow stack of running minima makes getMin O(1).”
2. For Min Stack, what must every push record?
Lesson 16's invariant: “A stack remembers the most recent unresolved opener — exactly what bracket nesting needs; a shadow stack of running minima makes getMin O(1).”
3. When a new element breaks monotonic order, what happens?
Lesson 17's invariant: “Keep the stack sorted; when a new element breaks the order, everything you pop just found its next-greater/next-warmer answer. Each index is pushed and popped once, so O(n).”
4. In the histogram problem, when do taller bars pop?
Lesson 18's invariant: “When a shorter bar appears, each taller bar you pop can no longer extend right, so finalize its rectangle. (Hard — go slow.)”
5. In postfix evaluation, an operator arrives. What happens?
Lesson 19's invariant: “Push operands; on an operator, pop two, combine, push the result — postfix needs no precedence rules.”
6. Why can a monotonic stack stay O(n)?
Lesson 17's invariant: “Keep the stack sorted; when a new element breaks the order, everything you pop just found its next-greater/next-warmer answer. Each index is pushed and popped once, so O(n).”
Self-check gate
Pass tonight if
At least two of your three chosen problems pass on run one or run two, and you can explain the monotonic-stack invariant without looking: keep the stack sorted; a breaking element makes popped items ready; each item is pushed and popped at most once.
If you miss the gate, do not erase the evidence. Add every failed problem to the next revision list with one root-cause line: wrong invariant, wrong pop condition, wrong operand order, missing empty-stack case, or missed edge case. Then compare with the source lesson for that exact problem.