Stack & Queue

  • Stack (LIFO): Last-In, First-Out. Essential for depth-first traversal, balancing parentheses, expression evaluation, and monotonic stack problems.
  • Queue (FIFO): First-In, First-Out. Core structure for Breadth-First Search (BFS) and task scheduling.

Common Patterns

  • Monotonic Stack: Next Greater / Next Smaller Element pattern.
  • Deque: Double-ended queue for sliding window maximum/minimum.

Solved Problems