meetings
array based on the start times of the meetings.available_rooms
with all room numbers (0 to n-1).ongoing_meetings
to keep track of rooms currently in use, storing pairs of end time and room number.room_meetings_count
to count the number of meetings in each room.meetings
array:
a. Release rooms from ongoing_meetings
that have become available (end time <= current meeting's start time) and add them back to available_rooms
.
b. If available_rooms
is not empty, allocate the room with the lowest number to the current meeting.
c. If available_rooms
is empty, take the room with the earliest end time from ongoing_meetings
and update the meeting's end time.
d. Add the allocated room and the updated end time to ongoing_meetings
.
e. Increment the count for the allocated room in room_meetings_count
.room_meetings_count
. If there is a tie, the room with the lowest number is chosen.