Two-Stack FIFO Queue

Asked at Microsoft · Coding Questions · Difficulty: Easy

Build a first-in-first-out (FIFO) queue out of two stacks. The queue must support adding an element at the back, removing and reading the element at the front, and checking whether it is empty, using only the ordinary operations of a stack.

Loading the problem…