Generate Available Time Slots
You are given a datetime range [startDate, endDate] and a weekly recurring working-hours configuration.
Generate every available 30-minute slot that is fully contained in the range and also lies inside one of the working-hour windows for the corresponding weekday.
Each slot is represented as a string "start,end", where the start and end timestamps are separated by a comma.
The first and last days must be validated using the exact time boundaries: a slot is valid only when slotStart >= startDate and slotEnd <= endDate.
Complete the function generateAvailableTimeSlots in the editor below.
generateAvailableTimeSlots has the following parameters:
String startDate: inclusive lower datetime bound inYYYY-MM-DD HH:MMformatString endDate: inclusive upper datetime bound inYYYY-MM-DD HH:MMformatString[][] workingHours: each row is[weekday, windowStart, windowEnd], whereweekdayis0for Monday through6for Sunday
Returns
String[]: all valid 30-minute slots in chronological order.
1Example 1
The 09:00-09:30 slot starts before the allowed range, and the 10:30-11:00 slot ends after the allowed range. The two middle 30-minute slots are fully contained.
2Example 2
Only the two full 30-minute slots inside both the Tuesday working window and the requested datetime range are returned.
Constraints
Limits and guarantees your solution can rely on.
workingHoursrepeats weekly.- Only full 30-minute slots are emitted.
- Output must be sorted chronologically.