Question d’entretien chez Google

Implement a queue with a limited numer of stacks.

Réponse à la question d'entretien

Utilisateur anonyme

20 févr. 2011

The queue can be implemented with two stacks. Always push into one stack A and pop from the other stack B. When B is empty and still need a pop, move all the elements from A to B. The amortized time complexity is still O(1).

2