Question DSA-QUE-0006
EasyWhy is list.pop(0) slow for a Python list used as a queue?
- A.
Lists can't hold numbers
- B.
Removing the first element shifts all the others: O(n)
- C.
Show answer and explanation
Answer: B
Use collections.deque, whose popleft() is O(1).