Question bank › Queue
Dsa Queue Medium

Hospital Bed Management

In a hospital system, patients arrive at various times needing beds but can only be accommodated if there are available beds. Each bed can accommodate only one patient at a time. Patients have a unique ID and a designated length of stay. When a patient is done with their treatment, they vacate the bed. Implement a system that tracks the occupancy of beds and outputs the order in which beds are vacated. Input consists of the number of beds followed by a series of patients (arrival_time, length_of_stay, patient_id). Output the order of patient_ids as beds are vacated. Example: Input: 2 0 4 1 2 2 2 3 5 Output: [1, 2].

Key concepts

queuelinked list

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.