Given 3 input parameters: numRooms: Int, appointmentStartTimes: List[Int], appointmentDurations: List[Int]
Return the usage number of the room that held the maximum appointments.
Notes:
- appointmentStartTimes array is sorted
- the rooms should be assigned in the order. Meaning if room #2 and #3 are vacant, we cannot execute next appointment in room 3, it has to be room #2.
Example:
numRooms: 3
startTimes: [1, 3, 8, 13, 20]
durations: [20, 3, 6, 2, 1]
Expected output: 3
Explanation:
- Room 1 is busy for the whole duration. So it is noticable that room 2 would be the next go to for the following appointments.
- Appoitment at idx 1, 3, 4 would be held in room 2.
Solution:
- Two heaps, full stop.
- Keep 2 heaps that keep busy rooms and available rooms. And use them as needed.
- To tackle the scenario where all rooms are busy, we would manually change the appointment start time to whenever the next room will be free and process the same appointment again meaning do not increment i in that scenario in the loop(bad practice but needed for optimal solution).
- So heap 1 key will be the end time of the ongoing appointment. Heap 2 will hold the vailable rooms in order.