Dsa
Queue
Medium
Limited Ticket Sales
A ticket booth sells a limited number of tickets to an event. Each customer requests a number of tickets, and only when the requested amount can be satisfied will they receive their tickets. If a customer cannot be accommodated with the current queue, they will go to the end of the queue. Implement a ticket sales function that will process the customers in a circular manner until all tickets are sold out.
Input:
The first line contains an integer T, the total number of tickets available.
The second line contains an integer N, the number of customers.
The next N lines contain a customer ID and the requested number of tickets separated by a space.
Output:
Print the customer IDs in the order they received tickets, one per line.
Example:
Input:
10
3
c1 3
c2 5
c3 4
Output:
c1
c2
c3
Key concepts
queuesimulationcircular queue
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