Interval Scheduling
5 min read.
Master the Merge Intervals pattern: sort by start time, then sweep once to merge every overlapping range into the minimal covering set. Shows up constantly in FAANG interviews as "Merge Intervals," "Meeting Rooms," and "Insert Interval."
Think of it this way: Picture a wall calendar covered in overlapping sticky notes representing scheduled meetings. Your goal is to consolidate every note that shares at least one minute with a neighbour into a single, bigger note — leaving only non-touching blocks behind. You pick up notes in order of their start time and ask: "Does this note touch or overlap the last block on my wall?" If yes, you extend that block (merge). If no, you pin a new block. One pass, done.
Sort by start: [1,3] [2,6] [6,7] [8,10] [15,18].
Check your understanding
Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.
Merge the intervals
Merge [1,3], [2,6], [8,10], [9,12], [15,18]. Fill in the merged result in order.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Quiz
20 questionsWhat is the first step in the Merge Intervals algorithm?
Done with this lesson?
Sign in free to keep your progress, streak and quiz scores.