Object-Oriented Programming · Pinterest · Medium
Part 1: Maximum Overlap After Every Booking — Sort the Endpoints, Then Use an Add-Max Segment Tree The timestamps themselves are irrelevant; what matters is the order of the distinct endpoints and the count on each gap between consecutive endpoints. Sort all $$2m$$ endpoints (for $$m$$ bookings), then the whole timeline collapses to at most $$2m-1$$ elementary segments. A booking [s, e) touches precisely the segments lying between s and e, which is a contiguous run of leaves…
Checking your access…