Question bank › Queue
Dsa Queue Medium

Hospital Patient Queue

You are building a queue system for a hospital where patients arrive with different severity levels (emergency, urgent, and standard). Implement a program that prioritizes patients based on their severity when serving them. Use the following input format: Input: - The first line contains an integer n (1 ≤ n ≤ 1000), the number of patient requests. - The next n lines contain commands: 'ARRIVE <severity> <patient_id>' where <severity> is 'E', 'U', or 'S' for emergency, urgent, or standard respectively. 'SERVE' processes the next patient based on priority (emergency > urgent > standard). Output: - Print the patient IDs in the order they were served. If no patients are available to serve, print 'No patients to serve'. Example: Input: 5 ARRIVE E 1001 ARRIVE U 1002 SERVE ARRIVE S 1003 SERVE Output: 1001 1002

Key concepts

queueprioritymulti-stage

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.