Dsa
Queue
Medium
Customer Service Call Handling
You are the manager of a call center, where calls from customers are managed in a queue. Each call has an associated priority (higher numbers indicate higher priority). Customers can either call in or hang up, represented by commands 'call <priority>' and 'hangup'. Your task is to process a series of commands and print the IDs of the customers in the order they will be served.
Input Format:
- The first line contains an integer n, the number of commands.
- The next n lines contain the commands as described.
Output Format:
- A single line containing customer priorities in the order they will be served.
Example:
Input:
4
call 5
call 3
hangup
call 7
Output:
7 5 3
Key concepts
queueprioritysimulation
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