Queues
First-in, first-out collection for scheduling, BFS, and buffering.
Queues Practice Problems
Easy
4 problems- 360easy
Implement Stack Using Queues
Build last in, first out stack behaviour out of a single queue by rotating it after every push.
- 361easy
Number of Recent Calls
Count the requests from the last 3000 milliseconds by dropping expired times off the front of a queue.
- 362easy
Moving Average From Data Stream
Report the average of the last few numbers in a stream using a queue plus a running sum.
- 363easy
Number of Students Unable to Eat Lunch
Simulate students rotating to the back of a queue and count how many are left when the line gets stuck.
Medium
4 problems- 364medium
Design Circular Queue
Build a fixed size queue inside one block of memory, wrapping the back around to the start with modulo.
- 365medium
Design Circular Deque
Extend the circular buffer idea so values can be added and removed at both ends in constant time.
- 366medium
Reveal Cards in Increasing Order
Order a deck so the reveal routine shows cards smallest first, by running that routine on positions.
- 367medium
Dota2 Senate
Decide which party wins by racing two queues of seat numbers and banning the later senator each round.
Hard
2 problemsRelated concepts
| Topic | Description |
|---|---|
| Breadth-First Search | Explore level by level from a starting point, the go-to way to find the shortest path in an unweighted graph. |
| Arrays | Ordered indexable collection for O(1) access by position. |
| Linked Lists | Nodes linked by pointers — insert and delete without shifting a contiguous block. |
| Stacks | Last-in, first-out collection for undo, parsing, and nested work. |
| Hash Tables | Key-to-value lookup in average O(1) via hashing into buckets. |
| Trees | Hierarchical nodes with parent–child links for ordered and nested data. |