Implement a queue using two stacks.
Stacks are First-In-Last-Out while Queue's are First-In-First-Out. Drawing a visual may provide additional insight.
Using two stacks, mark one as 'in' and the second as 'out'. Implement the two methods of a queue as follows:

1. Push new element to 'in' stack

1. If 'out' is empty, pop each element of 'in' and push to 'out'.
2. Pop the top element from 'out'

With this method we do not even need any temporary variables. Each element will be pushed twice - once when pushing into 'in' and second when push into 'out' - and popped twice - pop from 'in' and pop from 'out' for dequeue.

Thoughts or alternate solution? Let us know in the comments below!