Which value leaves first?
Warm-up · Multiple choice · about 2 min
Start with an empty queue. Run enqueue A, enqueue B, enqueue C, dequeue, enqueue D. Then dequeue until the queue is empty. In which order do the values come out of those last dequeues?
Example 1
Input:
enqueue A, B, C; dequeue; enqueue D
Output:
B, C, D
Learn the idea first: Queues: enqueue, dequeue; circular buffer, a visual lesson.
More Queues: enqueue, dequeue; circular buffer problems
- Predict head and tail Warm-up
- Implement a circular queue Standard
- Number of recent calls Standard
- Spot the bug: the tail runs off the end Standard
- Moving average from a stream Challenge