Day 21 — Mixed practice: Stack

Mock day · 45-minute stack mix · choose 2–3 problems

Tonight's goal: choose a stack pattern under pressure, explain it aloud, then code from a blank file with a strict timer.

Tonight's protocol

Use the mock-day protocol: speak first, code honestly, compare after the timer.

  1. 0:00–0:04 warm up: answer the six MCQs below. No notes, no hints, one pass.
  2. 0:04–0:05 choose: pick two problems from the menu and star a third backup. At least one chosen problem must be monotonic stack.
  3. 45:00 strict timer: before each problem, spend one minute saying the pattern name, brute force, better approach, and time/space complexity aloud.
  4. Two-problem split: 0:00–0:22 problem 1, 0:22–0:42 problem 2, 0:42–0:45 self-check gate.
  5. Three-problem split: 0:00–0:15 problem 1, 0:15–0:30 problem 2, 0:30–0:43 problem 3, 0:43–0:45 self-check gate.
  6. Stuck rule: if stuck ten minutes inside a slot, read only the pattern name from this menu, then keep coding until the slot ends.

The problem menu

Pick 2–3 from this menu. Your set must include Daily Temperatures, Next Greater Element I, or Largest Rectangle in Histogram.

ProblemPattern nameTimer slot
Valid Parentheses Stack matching 12–15 min
Min Stack Shadow minima 15–18 min
Daily Temperatures Monotonic stack 18–22 min
Next Greater Element I Monotonic stack + hashmap 15–18 min
Largest Rectangle in Histogram Monotonic stack, extend left/right 25 min stretch
Evaluate Reverse Polish Notation Stack evaluation 15–18 min

Warm-up MCQs

1. Which invariant matches Valid Parentheses?

2. What must the helper stack track?

3. When should Daily Temperatures pop?

4. Spot the bug: histogram code pops on taller current bars.

5. For subtraction, why name first pop b?

6. Why can monotonic-stack loops stay O(n)?

Self-check gate

Pass tonight if all three are true

If you fail the gate, add the failed problem to the next revision. If the failure was pattern choice, add Daily Temperatures. If it was opener matching or minima, add Valid Parentheses or Min Stack. If it was operand order, add Evaluate Reverse Polish Notation.