def double_all(arr):
result = []
while arr:
x = arr.pop(0)
result.append(x * 2)
return result
Variables
n- length of the input array
Explanation
Looks linear - single while-loop, one element handled per iteration - but `arr.shift()` (and Python `arr.pop(0)`) is **O(n)** because every remaining element shifts left. `n` iterations × O(n) per shift = **O(n²)**. Output list takes **O(n)** space.