Problem Statement:
There is a Hospital which contain N rooms from 1 to N -1. There is a Queue of Patients outside the Hospital. Each patient will be served in a single room and each patient has a time duration that it will take for the treatment. The rooms are allocated to patients by the lowest index (if the room is free). Initially room1 will be given to the patient, then if the 2nd patient comes and the 1st room is still busy, then the room2 will be given to the 2nd patient. now suppose the 1st patient treatment is completed, and the room1 is free now, and a new patient comes, then room1 will be given to the new patient. Each Patient has a start time also (Consider this as appointment time for him, it needs not to be a time format, use Integer for this).
The patients standing in the queue are in non decreasing order of their start time. means if the first patient start time = 1, then the second patient start time will be >= 1. Now the rooms will be allocated to each patients one by one. we have to calculate that by the end when all the patients are treatment done, Which is the room in which the maximum no of patients have been entered?
Example:
if N = 2 rooms, and the patients are = 3, which are below
patient-1 = {start: 1, duration: 8}
patient-2 = {start: 1, duration: 2}
patient-3 = {start: 6, duration: 4}Now first patient will be assigned to room-1, second patient comes at the same time he will be allocated to room-2, now after time 2, room-2 will become free, but patient 3 will come at time 6 and at that time he will be allocated to room-2 as well. so finally room-2 is the room in which the max number of patients have entered.
Complete Interview Experience Here
https://leetcode.com/discuss/interview-experience/2072074/Google-or-Software-Engineer-L3-or-Banglore-or-May-2022-Reject