Stacks & Queues
Welcome to the Stacks & Queues module. You will learn about LIFO and FIFO constraints, Monotonic Stacks, and real-world queuing systems.
1. Module Contents
-
Introduction to Stacks & Queues
Understand Stacks (LIFO) and Queues (FIFO). Discover the hardware reality of Push and Pop operations, and learn why recursion is essentially just a Stack.
-
Master Stack operations like Push, Pop, and Peek. Learn how to implement a MinStack in O(1) time and discover why ArrayDeque is superior in modern Java.
-
Master the FIFO constraints of Queues. Learn to implement Queues using Linked Lists and Ring Buffers (Circular Arrays) while understanding trade-offs.
-
Master the Monotonic Stack and Queue patterns to solve Next Greater Element problems in O(N) time with optimal space constraints and implementation details.
-
Learn to build an expression evaluator. Master the Shunting-yard algorithm to convert infix expressions to Postfix notation (RPN) using Stacks effectively.
-
Master the Sliding Window Maximum problem. Learn how to optimize from a naive brute force approach to O(N) using a Monotonic Deque for technical efficiency.
-
Discover real-world uses of Stacks and Queues, including practical implementations for Browser History navigation, Undo/Redo tracking, and API Rate Limiting.
-
Module Review: Stacks & Queues
Review everything you learned about Stacks and Queues. Access interactive flashcards, study the complexity cheat sheet, and comprehensively review takeaways.
2. Practice
[!NOTE] Looking for hands-on algorithmic exercises? We have migrated all coding challenges for this module into the Problem Vault to give you a centralized, focused practice environment.
Module Chapters
Introduction to Stacks & Queues
Introduction to Stacks & Queues
Start LearningStack Operations
Implementing the Stack
Start LearningValid Parentheses: LIFO in Action
Valid Parentheses: LIFO in Action
Start LearningQueue Implementations
Implementing the Queue
Start LearningMonotonic Stack
The Monotonic Stack Pattern
Start LearningExpression Evaluation
Building a Calculator: Expression Evaluation
Start LearningSliding Window Maximum
The Hard Problem: Sliding Window Max
Start LearningReal World Applications
Where do we use them?
Start LearningModule Review: Stacks & Queues
You’ve mastered the strict rules of LIFO and FIFO. You can now build calculators, process browser history, and optimize sliding windows.
Start Learning