I have a program which I tried to implement with VecDeque and Vec. According to my understanding and from what I read in the docs, pop_back(VecDeque) is similar to pop(Vec) and push_back(VecDeque) is similar to push(Vec).
But in this program, It passes the test with Vec and fails the test with VecDeque.
I have went over the program 100 times and read the docs and I just can't figure this out.
Hi, your problem comes from capacity.
If you check the capacity of both collections when they are created, you'll notice they aren't the same, making your program fail at some point.
This is documented in both collections (emphasis mine):
Creates an empty VecDeque with space for at leastcapacity elements.