A busy block never shrinks
transcript
Bookings are sorted by start time. Close bookings join one block. One detail breaks many answers.
The buffer is two minutes. Gaps of two or less join the block. A gap of eight starts a new block.
A block runs until ten. A booking from two to four sits inside it. Setting the end to four shrinks the block.
Now the next booking looks far away. So a new block starts by mistake. The final count is wrong.
Compare the block's end with the booking's end. Keep the later one. It is a single line in the loop.
Try a booking from one to ten. Add one from two to four. Then one from twelve to thirteen: one block.
Bookings are sorted by their start times. Their end times are not in any order. So a later booking can end earlier than the block.
A booking joins when its gap is at most the buffer. Joining means it becomes part of the block. The block then keeps the later of the two ends.
A block only grows. Test a nested booking. Full breakdown in the lecture.