Implement Queue Using Array
Implement a queue using an array with the following operations:
enqueue(x): Push element x to the back of queuedequeue(): Removes the element from the front of queuefront(): Get the front elementempty(): Return whether the queue is empty
Given an array of operations and values, execute them and return the results.
Examples
Input: [["enqueue","enqueue","front","dequeue","front","empty"],[1,2,0,0,0,0]]
Output: [1,2,false]
Input: [["empty"],[0]]
Output: [true]
Hints
To handle the circular nature of the queue (to efficiently reuse space), consider using two pointers (front and rear) and a fixed-size array. When the rear pointer reaches the end, wrap it around to the beginning if there's space available.
Related Problems
Implement Queue Using Array
Implement a queue using an array with the following operations: