A tennis club has an unlimited number of courts. You are given a list of bookings, each with an id, a start time and a finish time. Assign every booking to a court so that no court is used by two bookings at the same time.
A booking uses its court from startTime up to, but not including, finishTime, so a booking can start on a court at the exact moment the previous booking there finishes.
Courts may also need maintenance. A court is closed for maintenanceTime time units after every durability bookings it hosts. If the booking that triggers maintenance finishes at time t, the court is free again at time t + maintenanceTime.
Courts are numbered 0, 1, 2, ... in the order they are first used. To keep the answer unique, assign bookings one at a time:
startTime. If two bookings start at the same time, process the one with the smaller bookingId first.startTime. A court is free if it is not hosting a booking and not under maintenance.Without maintenance, this rule always uses the minimum possible number of courts.
List<String> assignCourts(List<String> bookings)
bookings is "bookingId,startTime,finishTime".i lists the ids of the bookings on court i in increasing order of startTime, separated by commas.List<String> assignCourtsWithMaintenance(List<String> bookings, int maintenanceTime, int durability)
assignCourts, but every court needs maintenance as described above.durability = 1, a court needs maintenance after every booking.assignCourts.1 ≤ bookings.size() ≤ 100,0001 ≤ bookingId ≤ 1,000,000,000bookingId values are distinct.0 ≤ startTime < finishTime ≤ 1,000,000,0000 ≤ maintenanceTime ≤ 1,000,000,0001 ≤ durability ≤ 100,000Input: assignCourts(bookings = ["11,1,4", "12,2,5", "13,4,6", "14,5,8", "15,7,9"])
Output: ["11,13,15", "12,14"]
Explanation:
Input: assignCourts(bookings = ["7,10,20", "5,12,18", "3,10,15", "2,18,21", "9,15,22", "4,23,26"])
Output: ["3,9,4", "7", "5,2"]
Explanation:
Input: assignCourtsWithMaintenance(bookings = ["11,1,4", "12,2,5", "13,4,6", "14,5,8", "15,7,9"], maintenanceTime = 1, durability = 1)
Output: ["11,14", "12,15", "13"]
Explanation:
Input: assignCourtsWithMaintenance(bookings = ["21,0,10", "22,10,20", "23,20,30", "24,30,40", "25,35,45"], maintenanceTime = 15, durability = 2)
Output: ["21,22,25", "23,24"]
Explanation: