Which collections class is designed for fast appends and pops at both ends of a sequence?
Correct answer D. deque
Explanation
collections.deque, a double-ended queue, supports appends and pops from either end in approximately constant time. A list is fast at the right end, but inserting or popping at index 0 is O(n) because all other items must shift. deque is ideal for queues and sliding windows.
Answer checked How we write and check questions
Discussion