Dsa
Queue
Easy
Library Book Queue
In a library, patrons can reserve books, and there is a queue for each book being reserved. Implement a program that maintains a queue for each book reservation, processes reservations in the order they were received, and outputs the IDs of patrons who reserved each book in the order they are served. Input comprises an integer B representing the number of distinct books followed by B sections. Each section starts with an integer N (number of reservations), followed by N lines containing an integer ID (patron ID). Output the patron IDs in the order they are served for each book, each followed by a blank line. Example: Input: 2 3 100 101 102 2 200 201 Output: 100 101 102 200 201
Key concepts
queuelibrary systemsimulated environment
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