Two bookings overlap your dates. Is the car taken?
transcript
Two cars. One booking holds hours zero to forty-eight. Another holds forty-eight to ninety-six. You want twenty-four to seventy-two. Both bookings overlap your range. Is the car taken?
The obvious test: count the overlapping bookings. Two. Fleet of two. Sorry, no. But look closer. The two bookings never overlap each other. A car is free at every single moment.
The right test is the peak. Clip each booking to your range. Plus one at each start. Minus one at each end. Sort by time. Ends come first at the same hour. Walk it. Running count: one, zero, one, zero. The peak is one.
A car returned at hour forty-eight can leave at forty-eight. That is why ends sort first. Cars of a class are interchangeable, so the peak is the whole answer. Peak below the fleet? There is a car.
Don't count bookings. Find the peak.
Full breakdown in the lecture.