Queues & Deques Quiz
Editorial
16 questions across the two Queues & Deques lessons: queues and ring buffers, the simulations a queue runs, and the monotonic deque for windows and earlier answers. Pick an answer to see whether it's right and why. Nothing is saved, so you can take it again.
If one trips you up, its lesson is Introduction to Queues or Monotonic Deque: the Window's Maximum.
Quiz
1 / 16Multiple choice
A ring buffer with room for 6 has
head = 4 and count = 3. Which slot does the next enqueue write?Multiple choice
The same kind of ring, with room for 6, has
head = 5 and count = 2. Which slot holds the back value?Multiple choice
A Python queue of 100,000 items is drained with
list.pop(0). What's wrong with it?Multiple choice
A linked-list queue clears
head when its last node leaves but not tail. Enqueue 7, dequeue, enqueue 8. What does is_empty() return?Multiple choice
In JavaScript,
head is 0 and the capacity is 5. Which expression steps head back to the last slot, 4?Multiple choice
Number of Recent Calls gets pings at 1, 3000, 3001 and 6001. What does each call return?
Multiple choice
Moving Average with a window of 2 gets 4, 7 and −1. What does each call return?
Multiple choice
Reveal Cards In Increasing Order on the deck [1, 2, 3, 4]: what arrangement do you return?
Multiple choice
Find the Winner of the Circular Game with 7 friends, counting every 3rd: who's left?
Multiple choice
The maximum of every window of 3 in [6, 2, 5, 1, 7, 3]?
Multiple choice
A window of 3 has seen 4, 1 and 3. Which values does the maximum's deque hold, front first?
Multiple choice
The minimum of every window of 2 in [5, 3, 4, 1, 2]?
Multiple choice
Longest Continuous Subarray With Absolute Diff ≤ Limit on [1, 5, 6, 7, 8, 10, 6, 5, 6] with limit 4?
Multiple choice
Jump Game VI on [3, −2, −2, 5] with k = 2: what's the best score?
Multiple choice
Constrained Subsequence Sum on [2, −5, −5, 3] with k = 2?
Multiple choice
Shortest Subarray with Sum at Least K on [5, −10, 7, 2] with k = 9?