Hospital Doctor Assignment Wait Minimization
Hospital Doctor Assignment Wait Minimization
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
Output
More Arrays problems
Browse all coding problems →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