An alert counts on its last second
transcript
A dashboard asks one question. How many alerts fire at second three? One small comparison decides it.
Sort the starts. Sort the ends. Each question is two binary searches.
Count the starts at most three. That is one. Now subtract the alerts that stopped. Ends at most three removes the alert. Wrong. Ends below three keep it. Count one.
The alert starts at second one. It still fires at second three. It stops after second three.
Test this case before you submit. It is the one that fails most often. One alert, from second one to second three. Ask at second three. The answer must be one, not zero.
Starts work the same way, from the other side. An alert that starts at second three fires at second three. So count the starts at most t.
A hundred thousand alerts need about seventeen steps a search. Each question uses two searches.
Both ends of an alert count. Subtract only ends below t. Full breakdown in the lecture.