This problem was asked by Apple.
Implement a queue class using two stacks. A queue is a data structure that supports the FIFO protocol (First in = first out). Your class should support the enqueue and dequeue methods like a standard queue.
class Queue:
def __init__(self):
# Fill this in.
def enqueue(self, val):
# Fill this in.
def dequeue(self):
# Fill this in.
q = Queue()
q.enqueue(1)
q.enqueue(2)
q.enqueue(3)
print q.dequeue() # 1
print q.dequeue() # 2
print q.dequeue() # 3