Day 51 — Mixed practice: Heap

Mock day · 45–60 minutes · Days 45–49 heap mix

Tonight's goal: pick 2–3 heap problems, explain the heap choice aloud before coding, and prove you can answer the heap gate without outside prep.

Tonight's protocol

Use the mock / mixed day process: strict timer first, approach out loud, code second, compare after.

  1. 0:00–0:04: answer the warm-up MCQs below. Do not open a solution.
  2. 0:04–0:05: choose the timed set from the menu: two normal problems = 45 minutes, three normal problems = 60 minutes, or Median + one normal problem = 55 minutes. Median counts double.
  3. Before each problem: spend 90 seconds saying the pattern name, brute force, better approach, time, space, and: min-heap or max-heap, and what lives in it?
  4. During the timer: give normal problems 18–20 minutes each. Give Median up to 35 minutes. If stuck at 25 minutes, read only the pattern name, then try ten more minutes.
  5. Final 5 minutes: compare only after the timer ends. Write one Notion note per miss: invariant, bug, or gate answer to revisit.

The problem menu

Pick only from this menu. Explain aloud before typing.

ProblemPattern nameSlot
Kth Largest Element in an Array Heap top-k: min-heap size k Normal
Top K Frequent Elements Heap top-k: count, then size-k heap Normal
Merge k Sorted Lists K-way heap merge: one head per list Normal
Find Median from Data Stream Two heaps median: max-left, min-right Counts double
Task Scheduler Heap scheduling: max-heap plus cooldown queue Normal

Warm-up MCQs

1. Kth Largest asks for the kth largest value, not a full order. Which invariant applies?

2. A top-k heap reaches size k + 1. What must happen next?

3. What belongs in the heap for Merge k Sorted Lists?

4. In Median Finder, high has two more items than low. What failed?

5. A remaining task goes straight back into the heap immediately. Which rule breaks?

6. A problem asks for median after every stream insert. Which pattern name should you say?

Self-check gate

Pass bar

Before comparing, you can answer this for all five menu problems: min-heap or max-heap, and what lives in it? For your chosen problems, you also said the approach and complexity before writing code.

Failure path: if any heap direction or heap contents answer is unclear, add that problem to the next revision. Write one root-cause line such as WA: heap direction, WA: heap contents, WA: rebalance, or WA: cooldown. Re-solve it later from a blank file with no hints. If Median fails, add it as two revision slots because it counts double.