Meeting Rooms III

Try to solve the Meeting Rooms III problem.

Statement

Given an integer, rooms, which represents the total number of rooms, where each room is numbered from 0 to rooms - 1. Additionally, you are given a 2D2D integer array called meetings, where each element meetings[i] = [starti,endi][start_i, end_i] indicates that a meeting will be held in the half-closed interval [starti,endi)[start_i, end_i). Each startistart_i​ is unique.

Meetings are allocated to rooms in the following manner:

  1. Each meeting will take place in the unused room with the lowest number.

  2. If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting.

  3. When a room is vacated, the meeting with the earliest original start time is given priority for that room.

Your task is to determine the room number that hosted the most meetings. If there are multiple rooms, return the room with the lowest number.

Note: A half-closed interval [a, b) is the interval between a and b, including a and not including b.

Constraints:

  • 11 \leq rooms 100\leq 100

  • 11 \leq meetings.length 1000\leq 1000

  • meetings[i].length == 22

  • 0starti<endi100000 \leq start_i < end_i \leq 10000

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.