What goes in the blank?
# insert at the FRONT of a Python list of n items items.insert(0, x) # time: O(____)
Answer: n
A list is a contiguous array, so every existing element shifts right by one; use a deque for O(1).
Play Problem Solving ▸
# insert at the FRONT of a Python list of n items items.insert(0, x) # time: O(____)
Answer: n