Question bank › Queue
Dsa Queue Easy

Triage Jump-Queue

An emergency room uses a specific queuing rule. Patients have a name and a priority (1 for Emergency, 2 for Normal). Patients are served FIFO, but an Emergency patient jumps ahead of all Normal patients currently in the queue. They do NOT jump ahead of other Emergency patients who arrived before them. Process a series of 'ARRIVE Name Priority' and 'SERVE' commands. Input Format: A series of commands, one per line. 'ARRIVE [Name] [Prio]' or 'SERVE'. Output Format: For each 'SERVE' command, print the name of the patient. If the queue is empty, print 'NONE'. Example: Input: ARRIVE Alice 2 ARRIVE Bob 2 ARRIVE Charlie 1 SERVE SERVE Output: Charlie Alice

Key concepts

queueimplementation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.