A single demo screen at a conference can show one session at a time. Speakers have requested slots as half-open [start, end) intervals, and some requests clash. Write minRemovals(requests), which returns the fewest requests to reject so that no two remaining sessions overlap.
Half-open means sessions that touch (one ends at 60, the next starts at 60) do not overlap.
minRemovals([[0, 60], [30, 90], [60, 120], [0, 120]]);
// 2: keep [0, 60] and [60, 120]; reject [30, 90] and [0, 120]
minRemovals([[10, 20], [10, 20], [10, 20]]); // 2
minRemovals([[0, 10], [10, 20]]); // 0
minRemovals([]); // 0
start < end.Spotted a mistake or a rights concern? Report an issue