Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Max Overlapping Appointments

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Max Overlapping Appointments. 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.

You need to log in / sign up to run or submit.

Problem

The Children's Hospital of Philadelphia needs to identify the busiest simultaneous appointment period from a schedule of patient visits. Given appointment intervals, return the maximum number of appointments active at the same time.

Each appointment is represented as [start, end], where start and end are integer time values. Treat intervals as half-open: an appointment is active at start and inactive at end. Therefore, an appointment ending at time t does not overlap one starting at time t.

Formal Specification

Implement max_overlapping_appointments(appointments), where appointments is a list of integer pairs. Return an integer representing the maximum number of simultaneous active appointments. Return 0 for an empty list.

Constraints

  • 0 <= appointments.length <= 10^5
  • Each appointment contains exactly two integers
  • 0 <= start < end <= 10^9
  • Intervals use half-open semantics: [start, end)

Function Signature

def max_overlapping_appointments(appointments):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output