Question d’entretien chez Amazon

Design a stack with any number of queue

Réponse à la question d'entretien

Utilisateur anonyme

11 nov. 2012

2 Queues Enqueu : Just push the element on stack1 Dequeue: Check if there are any elements on stack2, if there are the pop element from stack 2. If it is empty then pop n-1 element from stack1 to stack2 and pop the last element from stack1.