Take the talk that ends first
transcript
A festival has eight talks. A visitor can sit in one at a time. Which talks should they pick? Pick the most, with no overlaps.
Here are the eight talks, from nine to nineteen. Talk H is long. It overlaps four other talks. G and F only touch. Touching is fine. A plan has no overlaps. We want the biggest plan.
Sort the talks by end time. Take a talk if it starts at or after the last end. Otherwise, skip it.
Sorted by end time, G comes first. Take it. F starts as G ends. Take it. H and C start too early. Skip them. B starts at twelve. Take it. A and E start too early. Skip them. D starts at sixteen. Take it. Four talks: G, F, B and D. No plan has more.
Earliest start takes the long talk H first. That blocks four talks, and gives only two. Earliest finish gives four talks.
Sort by end time. Then scan once. Full breakdown in the lecture.