Daily challenge for 2026-08-17
594. Ticket Counter Queue Jumpers
In a ticket counter queue, people are represented by unique integer IDs. Occasionally, a VIP with a negative ID jumps directly to the front of the queue. Normal people (positive IDs) join the back of the queue. Given a sequence of arrivals, simulate the final state of the queue.
When a positive integer is processed, append it to the back of the queue.
When a negative integer is processed, insert it at the very front of the queue.
Return the final queue as an array of integers.
Example:
Input: arrivals = [3, 5, -1, 8, -2]
Output: [-2, -1, 3, 5, 8]
Run this challenge interactively in Python or JavaScript when the app loads.