Dsa
Queue
Easy
Weighted Triage Queue
A hospital triage system manages two queues: Critical (C) and Stable (S). To ensure fairness while prioritizing emergencies, the doctor sees 3 Critical patients for every 1 Stable patient. If a queue is empty, the doctor sees whoever is available from the other queue. If both have patients, the 3-to-1 ratio must be strictly followed (3C, then 1S, then repeat). Patients in each category are seen in the order they arrived.
Example:
Input:
C C C C S S C
Output:
C C C S C C S
Key concepts
queueschedulingstarvation-prevention
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