Topic notebook / 03
Stacks & parsing
The most recently saved task is the next one to resume. That order makes stacks useful for nested expressions.
What to look for
- Identify exactly what must be saved.
- Push when entering a nested task.
- Pop when returning to the outside task.
Work through a question
3 availableClose a Nested Ledger
An account has an opening balance and a grouped adjustment note. Evaluate its whole-number additions, subtractions, and parentheses, then return the closing balance. No multiplication or division.
Hard / Stack + running total / interactiveWait for a Lower Quote
A workshop receives one material-price quote per day. For each day, return how many days it takes to see a strictly lower quote. Return 0 if no later lower quote exists. Equal prices do not qualify.
Medium / Monotonic stack / interactiveValidate Nested Crate Tags
A crate tag uses only (), [] and {} to mark nested groups. Return true only when every closing mark matches the most recent unclosed opening mark and nothing remains open.
Easy / Matching stack / interactiveWhere this leads
Keep following the branch when this pattern feels familiar.