2402. Meeting Rooms III
Practice Meeting Rooms III for free on NudgeCode: Hard, Greedy pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
There are n rooms numbered 0 to n - 1. Each [start, end] in meetings is a meeting over the half-open time range [start, end); all start times are different. Meetings are handled in order of start time:
- A meeting takes the free room with the lowest number.
- If no room is free, it waits until the earliest room frees up (lowest number on a tie) and then runs for its original length.
Return the number of the room that hosted the most meetings, choosing the lowest number on a tie.
Example
n = 2, meetings = [[0,10],[1,5],[2,7],[3,4]] -> 0
Constraints
- 1 <= n <= 100
- 1 <= meetings.length <= 10^5
- 0 <= start < end <= 5 * 10^5