Dsa
Queue
Easy
Service Center Request Queue
In a service center, requests come in for repairs and can be handled in a FIFO manner. Customers can both request service and cancel their requests. Write a program that maintains the order of service requests and prints the final list of requests being processed.
Input Format:
- The first line contains an integer N: the number of actions.
- The next N lines contain either "REQUEST <request_id>" to add a request or "CANCEL <request_id>" to cancel a request.
Output Format:
- Print space-separated list of IDs of requests being processed.
Example:
Input:
5
REQUEST R001
REQUEST R002
CANCEL R001
REQUEST R003
CANCEL R002
Output:
R003
Key concepts
queueprocessing
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