Assign Meetings and Find the Most-Used Room
Company: Bytedance
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
# Assign Meetings and Find the Most-Used Room
There are `n` rooms numbered from `0` through `n - 1` and meetings `[start, end]` with distinct start times. Process meetings by increasing start time.
- If one or more rooms are free at a meeting's start, assign the available room with the smallest number.
- If no room is free, delay the meeting until the earliest room becomes free, preserving the meeting's original duration. If several rooms become free at that earliest time, use the smallest room number.
Return the room that hosts the most meetings. Break a count tie by returning the smallest room number.
## Function Signature
```python
def most_used_room(n: int, meetings: list[list[int]]) -> int:
...
```
## Constraints
- `1 <= n <= 100_000`
- `1 <= len(meetings) <= 200_000`
- `0 <= start < end <= 1_000_000_000`
- Meeting start times are pairwise distinct.
- Delayed end times may exceed the largest original end time. Under these input bounds, every delayed time remains below `201_000_000_000_000`, within the exact integer range shared by the supported runtimes.
## Example
```text
Input: n = 2, meetings = [[0, 10], [1, 5], [2, 7], [3, 4]]
Output: 0
```
```text
Input: n = 3, meetings = [[1, 20], [2, 10], [3, 5], [4, 9], [6, 8]]
Output: 1
```
Quick Answer: Practice an interval-scheduling problem where meetings may be delayed and room-number tie rules affect the final count. The prompt tests precise simulation, large-input complexity, integer safety, and careful handling of simultaneous room availability.