IntermediateAbout 20 min

    Interval Scheduling

    Read the full article on Substack

    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.

    0246810121416181–312–626–738–10415–185

    Sort by start: [1,3] [2,6] [6,7] [8,10] [15,18].

    1/7

    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

    Schematic

    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.

    merged 1
    merged 2
    merged 3
    3 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    What is the first step in the Merge Intervals algorithm?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going