Frage im Vorstellungsgespräch bei Fivestars

Implement a queue with two stacks (enqueue, dequeue, peek)

Antwort im Vorstellungsgespräch

Anonym

9. Sept. 2016

To enqueue, pop all of stack B onto onto stack A, push onto stack A. To dequeue, pop all of stack A onto stack B, then pop stack B. To peek, pop all of stack A onto stack B, then peek stack B.