Dynamic array

Append numbers and watch how many slots remain free.

When the last slot fills, allocate a buffer twice as large for the next append.

Move one number at a time, keeping its index. The new buffer then becomes the active one.

Appending into free space takes O(1), resizing takes O(n). A sequence of appends takes O(1) amortized time per append.