Meeting Rooms III
Hard · Heap & Priority Queue · about 30 minutes
Asked at Google, Microsoft, Amazon, Meta, Bloomberg.
n rooms are numbered 0..n-1. Each meeting [start, end] in meetings occupies the time interval [start, end), and no two meetings start at the same time. Assign meetings to rooms in order of their start time:
- If any room is free, the meeting goes to the free room with the smallest number.
- Otherwise the meeting waits for the first room to become free and then runs for its full original
length. If several rooms free up at the same moment, it takes the smallest-numbered one.
Return the room that hosted the most meetings; break ties in favor of the smallest room number.