Build a doctor appointment scheduling system: doctor can add availability (datetimes), patient can schedule an appointment, schedule a recurring appointment, cancel an appointment, and given a doctor retrieve available blocks of time by interval (e.g. 30-minute Calendly-style slots).
Asked in the technical phone screen stage. 60-minute live coding (Python).
Implement schedule_appointments(operations). Each operation is a dictionary with an action. Datetimes are ISO strings and use half-open intervals [start, end). Return one result per operation: availability returns true, scheduling returns true or false, recurring scheduling returns created IDs or [], cancellation returns true or false, and availability queries return [start, end] slot pairs.
def schedule_appointments(operations):