On Halloween night, a line of trick-or-treaters has formed at the local candy stand. Each trick-or-treater either arrives at the end of the line or leaves from the front. You are given an array of operations representing the events. There are two types of operations:
x
(which can be a number or string) joins the back of the queue.Your task is to simulate these operations on an initially empty queue and return the final state of the queue as an array (from front to back).
Example:
For the input operations:
["ENQUEUE Alice", "ENQUEUE Bob", "DEQUEUE", "ENQUEUE Charlie", "ENQUEUE Dave", "DEQUEUE"]
The simulation would proceed as follows:
Output: ["Charlie", "Dave"]
Implement the function to achieve this simulation.