← Intervals · guided lesson

Intervals

1 / 18 · story

the story

Interval merging (sort by start)

Every tool here exists because something was too slow or broke without it. Here is what.

A folklore technique with no single inventor: it's what any "union of ranges" code does after sorting. The HTML standard even requires browsers to keep a video's buffered ranges merged this way.

why it matters: without it

Overlapping ranges get double-counted (coverage looks bigger than it is), and every free-slot search compares every pair.

also in this chapter: Interval scheduling (earliest finish first) · Interval partitioning (rooms = maximum overlap) · Sweep line & difference array