Stacks & Queues
3 programs — patterns, complexity, and code
| # | Program Name | Pattern | Time | Space | Key Idea | Level |
|---|---|---|---|---|---|---|
| 1 | isValidParentheses | Stack | O(n) | O(n) | Push opens; on close, check if top of stack is the matching open bracket. | Simple |
| 2 | dailyTemperatures | Monotonic Stack | O(n) | O(n) | Maintain a decreasing stack of indices; pop when a warmer day is found. | Middle |
| 3 | slidingWindowMaximum | Monotonic Deque | O(n) | O(k) | Keep a decreasing deque of indices; front is always the max of current window. | Complex |