Must-do problems: Queues and Stacks
150 min · Intermediate
Need help? Ask a tutor on WhatsApp (opens in a new tab)Each problem is solved by asking one question: which value must come out next? The oldest means a queue, the newest means a stack, either end means a deque, and the most important means a priority queue. Read the input with Scanner, solve every problem with the right structure from java.util, and run every test before opening a hint.
What you will learn
- Choose a queue, a stack, a deque or a priority queue from the order a problem needs
- Solve matching and undo problems with a stack
- Simulate waiting lines with a queue and a priority queue
- Use a heap for top-K and a deque for sliding-window problems
Sign in to continue this lesson
Create an account to read every lesson, practise with the exercises and keep track of your progress.