Using Stack structure only to implement Queue. How to enqueue, dequeue?
Anonymous
Have 2 stacks, called IN and OUT. The queue operation becomes IN.push(e). For the dequeue operation, if OUT is not empty, just return OUT.pop(). If OUT is empty, pop everything from IN and push it into OUT, then return OUT.pop().
Check out your Company Bowl for anonymous work chats.