Dsa
Queue
Medium
Circular Restaurant Queue
You are managing a restaurant with a circular queue for seating customers. Each customer arrives at a certain time and waits until a table is available. If a table is available, they are seated immediately. If not, they join the end of the queue. The restaurant can serve a maximum of `N` customers at a time. Given the arrival times of customers and how long they will take to eat, determine the order in which customers are seated. Each customer is represented by their arrival time and dining duration in seconds. A customer is represented as (arrival_time, duration). Input consists of the integer `N` followed by a list of tuples representing (arrival_time, duration). Output the order of customers as a list of their indices (0-based). Example: Input: 3 0 10 1 2 2 5 4 1 Output: [0, 1, 2, 3].
Key concepts
queuesimulation
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