Queue Simulator

Queue Data Structures Simulation

Problem: Queue Simulator

You are tasked with simulating basic operations on a queue of integers. Your function will receive an array of operation commands and should execute them in the order provided.

Operations

The operations will be provided as strings. The commands are:

  • enqueue X: Add integer X to the back of the queue.
  • dequeue: Remove the element from the front of the queue. If the queue is empty, do nothing.
  • front: Retrieve the element at the front of the queue. If the queue is empty, return -1.
  • size: Return the current number of elements in the queue.
  • empty: Return 1 if the queue is empty; otherwise, return 0.

Your function should return an array of outputs corresponding to the operations that produce a result (i.e. front, size, and empty).

Example

For the input:

enqueue 10
enqueue 20
front
dequeue
front
size
empty

The output should be:

[10, 20, 1, 0]

Note

Today, on November 11 (Veterans Day), we honor those who serve. In the spirit of service, aim to write clean, well-documented code that can help others understand your logic.


Starter Code

Below is language-agnostic starter code for various languages to help you begin your solution.