V.resize() instead of v.reserve()

Won’t the resize() function work the same way as that of reserve? We can initially resize the vector to 1000 and then when the capacity reaches 1000 , the capacity will double.

@ps_1625 hey ,basically the msin difference between resize and reserve is that resize is used to change the size of vector whereas reserve dors not.Reserve is only use to store at least the number of specified elements without having to reallocate memory ,but in resize if no is smaller than current number then it resizes the memory and deletes the excess space over it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.