Cancel the fewest: keep the most
transcript
One meeting room. Eight requests for one day. No two may overlap. Cancel as few as you can.
Each bar is a request. Request C is long. It overlaps five others. Fewest cancelled means most kept. So we want the largest set with no overlap. Which key should we sort by?
Sort the requests by end time. Keep a request if it starts at or after the last end. Otherwise, skip it. The sort makes the choice. One pass applies it.
H ends first. Keep it. G starts too early. Skip it. B starts at ten. Keep it. A and C start too early. Skip both. Keep E, then D, then F.
Earliest start takes the long request. It keeps only three. Earliest end keeps five.
G, A and C are cancelled. Eight minus five is three. No plan cancels fewer. Sort by end time. Then scan once. Full breakdown in the lecture.