Question bank › Queue
Dsa Queue Medium

Library Queue Management

You manage a small library's book lending system. Books are lent out and returned in a first-come, first-served order. A queue is implemented for this process. Your task is to simulate the lending and returning of books based on a series of commands. Each command can be either 'lend <book_id>' to lend a book or 'return <book_id>' to return a book. Output the order in which books are lent out in a single line when all commands are processed. Input Format: - The first line contains an integer n (1 <= n <= 1000), the number of commands. - The next n lines contain one command each in the format described above. Output Format: - A single line of space-separated book IDs representing the order of lent books. Example: Input: 5 lend 101 lend 102 return 101 lend 103 return 102 Output: 101 102 103

Key concepts

queuesimulationdata-structure

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.