← Back to TypeScript
Stacks and Hash Maps
A stack remembers what it is waiting for — a matching paren, a pending warmer day. A hash map remembers where it has already been. Between them sit most linear-time interview tricks.
Balanced delimiters
intermediateblankComplete the stack that matches brackets — the push, the pop, and the emptiness check that together decide balance.
Challenge: days until a warmer day
advancedchallengeFor every temperature, return how many days until a warmer one — in one pass with a stack of pending days.
Challenge: the first character that is unique
intermediatechallengeFind the index of the first character that appears exactly once — two passes, one hash map.
Review: the minimum that survives nothing
advancedreviewA MinStack answers every min correctly until the element holding the minimum is popped. The previous minimum is gone forever. Find why.