You are given a list of tennis court bookings. Each booking has a start time and an end time.
Task
Return an assignment plan that:
-
Assigns
each booking
to a specific court (e.g., court IDs
1..k
).
-
Ensures
no court has overlapping bookings
.
-
Uses the
minimum number of courts
(assume unlimited courts are available).
You may return:
-
The
minimum number of courts
needed, and
-
An
array of court IDs
aligned with the input bookings (i.e.,
assignment[i]
is the court used by booking
i
).
Follow-up: Maintenance buffer
After a booking ends, the court is unavailable for a fixed maintenance time M (e.g., minutes). That means a booking [s2, e2] can reuse the same court after booking [s1, e1] only if:
Update your approach to support this requirement.
Notes / Assumptions
-
Time can be treated as integers.
-
You should aim for an efficient solution (e.g., for large
n
).