Skip to content

Stacks & Queues

Problem Complexity Key Pattern
Daily Temperatures O(n) -- each index pushed and popped at most once Next-greater-element pattern — "next warmer day", "next higher price",
Min Stack O(1) for all operations Augmented data structure for O(1) aggregate queries — "get min/max
Valid Parentheses O(n) -- single pass Matching/nesting validation — balanced brackets, HTML tags, expression