Dsa
Queue
Easy
The Load-Balancing Bank
A bank has N tellers, each with their own queue. When a customer arrives, they join the queue with the fewest people. If multiple queues have the same minimum number of people, the customer chooses the one with the lowest index (e.g., Teller 1 before Teller 2). Given N and a list of customer names, output the final state of each teller's queue.
Example:
Input: 2 Alice Bob Charlie Dave
Output:
T1: Alice Charlie
T2: Bob Dave
Explanation:
- Alice joins T1 (both empty).
- Bob joins T2 (T1 has 1, T2 has 0).
- Charlie joins T1 (both have 1, pick lowest index).
- Dave joins T2 (T1 has 2, T2 has 1).
Key concepts
queuesimulationload-balancing
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