Interview questions · Assort Health
Build Lab and Consultation Appointment Matches
Validate 10-minute provider availability records, merge contiguous slots by provider and appointment type, generate every 30-minute appointment at 10-minute steps, and return all lab-then-consultation pairs whose wait is at most 60 minutes.
Implement match_appointment_flow(records: list[list[str]]) -> list[str].
Valid Input Domain
Each valid raw record is [provider, appointment_type, start, end]. The type is Lab or Consultation, and times use 24-hour HH:MM. Discard a record if fields are missing, either time is malformed, the interval crosses midnight, or its duration is not exactly 10 minutes. Remove exact duplicate valid records.
For each provider and type, merge contiguous 10-minute records into maximal availability intervals. From each interval, generate every 30-minute appointment at 10-minute start increments. Pair a Lab appointment with a Consultation appointment when the consultation starts at or after the lab ends and no more than 60 minutes after it.
Encode a match as "labProvider|labStart-labEnd|consultProvider|consultStart-consultEnd". Sort matches by lab start, consultation start, lab provider, then consultation provider, all ascending. Return every match in that order.
Constraints
0 <= records.length <= 100,000- Provider names contain neither
|nor-.
Public Examples
Example 1
Input: [["L1", "Lab", "09:00", "09:10"], ["L1", "Lab", "09:10", "09:20"], ["L1", "Lab", "09:20", "09:30"], ["C1", "Consultation", "09:40", "09:50"], ["C1", "Consultation", "09:50", "10:00"], ["C1", "Consultation", "10:00", "10:10"]]
Output: ["L1|09:00-09:30|C1|09:40-10:10"]
Example 2
Input: [["L1", "Lab", "09:00", "09:10"], ["L1", "Lab", "09:10", "09:20"], ["L1", "Lab", "09:20", "09:30"], ["C1", "Consultation", "11:00", "11:10"], ["C1", "Consultation", "11:10", "11:20"], ["C1", "Consultation", "11:20", "11:30"], ["bad"]]
Output: []
Hint: Normalize time before combining intervals
Represent valid times on one integer scale so duration checks, adjacency, sliding windows, waits, and sorting use the same comparisons.
Community answers
Nothing here yet.
Join in on CSWork →