Vectors
Explore the use of vectors in C++, focusing on their dynamic resizing features, common operations like insertion and deletion, and their time complexities. Understand how vectors differ from arrays and how to effectively utilize vectors for efficient problem-solving in competitive programming.
We'll cover the following...
We'll cover the following...
Array vs Vector
Many times, you need a structure like an array that is dynamic in size. Vectors are dynamic arrays. Vectors, similar to an array, have contiguous memory allocation so that random access is for vectors as well.
One way to implement vectors using an array is to copy the array to a new array of double the size every time the first array is full. The amortized time complexity is ...