implement queue with two stacks
Anoniem
Maintain the queue in stack1 in reversed order. If you want to retrieve the head pop the contents of stack1 into stack2, reversing it in the process. Now pop the head from stack2 and pop the rest of the items back into stack1, putting them in previous order.