Your question is Find Most Efficient Available Slot. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Headway Scheduling receives a provider's booked appointment intervals and must find the earliest available slot within a working window. Given the required appointment duration, return the earliest slot that does not overlap any booking.
Booked intervals may overlap or be adjacent, and the input is not sorted. Treat times as integer minute offsets, with intervals represented as [start, end), meaning start is occupied and end is available.
Implement find_available_slot(booked, day_start, day_end, duration).
booked is a list of two-element integer lists [start, end].day_start and day_end define the provider's available working window.duration is the required appointment length in minutes.[slot_start, slot_end] for the earliest valid slot, or [] if none exists.day_start or end exactly at day_end.def find_available_slot(booked, day_start, day_end, duration):