Dsa
Queue
Easy
The Hybrid Checkout Ratio
A supermarket has one cashier serving two queues: 'Express' (customers with 5 or fewer items) and 'Regular'. To keep the express line moving, the cashier follows a strict 2-to-1 ratio: they serve 2 customers from Express, then 1 from Regular. If a queue is empty, the cashier serves whoever is available from the other queue. If both have customers, the ratio rule must be reset only after a Regular customer is served or if the Express queue becomes empty.
Input: N (number of customers). Then N lines: 'E' or 'R' (Queue Type) followed by the customer name.
Output: The names in the order they are served.
Example:
Input:
4
E Alice
E Bob
E Charlie
R Dave
Output:
Alice
Bob
Dave
Charlie
Key concepts
queuescheduling
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