⌘K
Flycodx

Hospital Doctor Assignment Wait Minimization

Hospital Doctor Assignment Wait Minimization

HardArrays100% accepted

Mumbai Central Hospital assigns patients to doctors based on appointment availability. Dr. Sharma works 9:00-10:00, Dr. Priya works 9:30-11:00. Patients arrive at [9:15, 9:45, 10:30]. Find assignment minimizing maximum wait time. Rule: consultations take exactly 15 minutes (times are HHMM-style integers treated as plain numbers). Patients are processed in arrival order; each picks the doctor giving the earliest possible start (>= arrival, >= window start, >= when that doctor is free, and start+15 <= window end). Return the maximum wait (start - arrival); -1 if any patient cannot be seen. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Each patient (arrival time) takes the doctor that minimises their wait. A doctor with window [start,end] can serve arrival a only if a <= end; wait = max(0, start-a). Return the maximum wait over all patients, or -1 if any patient has no doctor with end >= arrival. solve(patients, doctors).

Input

patients=[915,945,1030] doctors=[[900,1000],[930,1100]]

Output

0
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3