How to implement a queue using stack?
How to implement a queue using stack?
A queue can be implemented using two stacks. Let queue to be implemented be q and stacks used to implement q be stack1 and stack2. q can be implemented in two ways:
Method 1 (By making enQueue operation costly)
Method 2 (By making deQueue operation costly) See Implement Queue using Stacks