$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · medium · #309

What goes in the blank?

# insert at the FRONT of a Python list of n items
items.insert(0, x)
# time: O(____)

Answer: n (also accepted: n)

A list is a contiguous array, so every existing element shifts right by one; use a deque for O(1).
Play Problem Solving ▸