Queues and arrival order

List the jobs removed in order. Return "Empty" for a removal when no job is waiting.

Examples

Example 1

Input
Add A, add B, remove, add C, remove, remove, remove
Expected output
A, B, C, Empty

Hints and solution

Hint 1

Separate arrival order from positions in the queue after removal.

Reveal worked answer

The first removal serves A. When C arrives, B has been waiting longer. The next two removals serve B, then C. At that point there are no jobs left.

Back to the lesson