Ends come before starts
transcript
Two meetings. Zero to five, and five to ten. How many rooms?
The sweep makes a plus one at each start. It makes a minus one at each end. It sorts them by time and keeps the largest count.
At minute five, an end and a start have the same time. If the start goes first, the count reaches two. If the end goes first, the count stays at one.
The end minute is free. The room is free again at minute five. So the end must be counted first.
The code keeps each event as a pair, time and change. A minus one sorts before a plus one at the same time. So the sort puts the end first. No extra rule is needed.
We ran six meetings. The wrong order gives four rooms. Ends first gives three, which is correct.
Which ends count decides the answer. Full breakdown in the lecture.