Why appending is amortized O(1)
Most appends just drop the value into a free slot — one cheap step. But when the array is full, it must allocate a doubled array and copy everything over, an expensive O(size) spike. Those spikes are rare enough to average out.