Hand out rooms in order of start time, keeping each room’s end time in a min-heap. If the room that frees up first is free when the next meeting starts, reuse it; if not, no room is free, so open a new one.
- Average time
- O(n log n)
- Space
- O(n)
Hand out rooms in order of start time, keeping each room’s end time in a min-heap. If the room that frees up first is free when the next meeting starts, reuse it; if not, no room is free, so open a new one.