#419 · Heaps · Advanced · 160 XP · about 35 min
A co-working space has n meeting rooms numbered 0 to n - 1. Each meeting (start, end) wants a room from time start up to time end (a room that frees up at time t can take a meeting that starts at t). Every start time is different, and meetings are handed out in order of start time by these rules:
Write busiest_room(n, meetings) that returns the number of the room that hosted the most meetings. If several rooms tie, return the lowest number.
busiest_room(2, [(0, 10), (1, 5), (2, 7), (3, 4)]) # returns 0 busiest_room(3, [(1, 20), (2, 10), (3, 5), (4, 9), (6, 8)]) # returns 1
In the first example room 0 takes the meeting at 0 and room 1 the meeting at 1. The meeting that wanted to start at 2 waits for room 1, which frees up at 5, and runs from 5 to 10. The meeting that wanted to start at 3 waits until 10, when both rooms free up, and takes room 0. Each room hosted two meetings, so the answer is 0.
First solves only, ranked by stars and then time.