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:

  1. A meeting takes the free room with the lowest number.
  2. 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