Sort the shows by end
transcript
Shows run on air for some seconds. A notification reaches shows on air. Send the fewest. The first idea is to go in time order.
One show runs from one to ten. Two short shows run from two to three, and five to six. How many notifications do you need? The long show starts first, and ends last.
Sorted by start, the long show comes first. A notification at ten reaches only that show. Sorted by end, three and six reach all. The short shows never get a notification.
Sort the shows by end. Send at the end of the first unreached show. Skip every show that is already reached. An early end reaches the most later shows.
Sorted by start, the count is one. Sorted by end, it is two. Two is right. A long early show always exposes the wrong sort.
Test a long early show. It exposes the wrong sort. Full breakdown in the lecture.