My idea (which theoretically should work is:
- Pop the stack into the queue (this will lead to queue)
2.Push the queue back into the stack after the stack is empty
with the LIFO nature of the stack and FIFO nature of the queue this should work. But I'm having issues with the implementation.
The error given is that my queue is full on line 19 (when it's attempting to enqueue), however I have set the capacity as the same size of the stack that I'm trying to reverse so I don't see where the issue lies, the loop should stop when the stack is empty, and therefore there's no real reason for this to not work as far as I can see.
The implementation of stack/queue is done from a template so that cannot be the issue.
I am just looking for tips, if it's possible and not a full solution.