The Sweep Line
Merging and room-counting as one animation.
This animation shows meetings as colored horizontal bars on a timeline, and runs the two core interval sweeps on them.
First comes the step every interval algorithm shares: the bars slide into start order. Watch how much calmer the picture gets — once sorted, each bar can only interact with its immediate neighbors.
In merge mode, a vertical scan line sweeps left to right. When it reaches a bar that starts before the previous bar has ended, the two fuse into one wider bar with a squish. Watch the fused bar's right edge: it takes the maximum of the two ends, which is why a short bar swallowed by a long one doesn't shrink the result.
In room-counting mode, the same bars stack into rows instead. Each bar drops into the first row where it fits without overlapping; when no row is free, a new row opens and the rooms badge ticks up. The number of rows at the end is the maximum number of meetings alive at the same instant — the answer to Meeting Rooms II.
Pay attention to bars that touch end-to-start, like one ending at 10 and one starting at 10: they share a row. Ends are processed before starts on ties, which is exactly the tie-break rule from the theory lesson.