Schedule meetings across rooms and report which room hosts the most meetings when rooms become available at different times.
You are given a set of meeting requests, each with a start time and an end time. There are n meeting rooms labeled from 0 to n - 1.
A meeting is assigned to the smallest-index room that is free at its scheduled start time. If no room is free, the meeting is delayed until the earliest room becomes available, and it keeps the same duration.
After all meetings are processed, return the index of the room that hosted the most meetings. If multiple rooms hosted the same maximum number, return the smallest index among them.
n: number of meeting roomsmeetings: array of [start, end] pairs1 <= nmeetings.length >= 1start < endn.meetings, where each interval is [start, end].Example 1
Input
n = 2 meetings = [[0,10],[1,5],[2,7],[3,4]]
Output
0
Explanation
Room 0 takes the first meeting. Room 1 takes the second. The third meeting is delayed until room 1 frees up, and the fourth meeting is also delayed. In the end, room 0 hosts more meetings than room 1.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.