Skip to content
Onsite

Minimum Number of Platforms

MediumP2Coding

Given the arrival and departure times of the trains at a station, find the smallest number of platforms such that no train has to wait. Times are strings in 24-hour "HH:MM" format, and train i uses a platform during [arrival[i], departure[i]). A platform freed at some minute can be used by a train arriving at that same minute. All trains arrive and depart on the same day, and each departure is after its arrival.

Example 1

Input
arrival = ["09:00","09:40","09:50","11:00","15:00","18:00"], departure = ["09:10","12:00","11:20","11:30","19:00","20:00"]
Output
3
Why
Between 11:00 and 11:20 three trains are in the station.

Example 2

Input
arrival = ["09:00","10:00"], departure = ["10:00","11:00"]
Output
1

Constraints

  • 1 <= n <= 10^5
  • Times are valid HH:MM between 00:00 and 23:59
  • departure[i] is later than arrival[i]

Hints

Run checks the 3 visible tests, Submit all 9.