Atlassian’s facilities team needs to assign tennis bookings to specific courts. Given booking intervals, assign every booking a court so overlapping bookings never share a court, while using the minimum possible number of courts.
Implement assign_courts(bookings). Each booking is represented by [start, end], where start and end are integers and start < end. Return a dictionary with court_count, the minimum number of courts required, and assignments, a list where assignments[i] is the zero-based court ID assigned to bookings[i].
Bookings that end at time t may share a court with a booking that starts at time t. Court IDs should be assigned deterministically by always reusing the available court with the smallest ID. When multiple new courts are needed, allocate the next smallest unused ID.
def assign_courts(bookings):