algorithm - A way to reverse queue using only two temporary queues and nothing more? -
There is only one way to not use two temporary queues (and any other variables, such as counter) in the queue ? Only standard queue operations are available: Enqueu (E), Decqu (), MPT ()?
The solution is welcome in any language or pseudocode.
You can:
- Push all the elements of the original line on this stack.
- Now populate each element from stacks and add it to the original line.
Comments
Post a Comment