Loading...
Loading...
Loading...
A help desk keeps a line of customers. enqueue x adds customer x at the back. dequeue removes the customer at the front and prints them. front prints the front customer. size prints how many customers wait. For an empty line, dequeue and front print EMPTY.
enqueue x, dequeue, front or size.Example 1
Input
6 enqueue 5 enqueue 8 front dequeue size dequeue
Output
5 5 1 8
Prints 5, 5, 1 and 8.
Example 2
Input
3 dequeue size front
Output
EMPTY 0 EMPTY
Try the problem first. Open one hint at a time.
Use collections.deque: append at the back, popleft from the front.
A list with pop(0) would be too slow for 100000 commands.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor