Minimum Railway Platforms
Updated
Problem statement
Given equal-length arrays of train arrival and departure times, return the minimum number of station platforms required so that no train waits.
Each pair at the same index describes one train. Time values are comparable integers on one day. If one train arrives at the exact time another departs, both occupy a platform at that instant, so the arrival is processed first.
Function
minimumPlatforms(arrivals: int[], departures: int[]) → intExamples
Example 1
arrivals = [900,940,950,1100,1500,1800]departures = [910,1200,1120,1130,1900,2000]return = 3Three trains overlap around time 1100.
Example 2
arrivals = [900,1100,1235]departures = [1000,1200,1240]return = 1No two train intervals overlap.
Constraints
1 <= arrivals.length == departures.length <= 2000000 <= arrivals[i] <= departures[i] <= 10^9- All times belong to one comparable timeline.
Source note: Interview prompt excerpt preserved as source evidence.
More MakeMyTrip.com Onsite Interview questions
Similar questions at other companies
- Maximum Non-Overlapping IntervalsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Removals for Non-Overlapping IntervalsByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
- Minimum Points Hitting Every Closed IntervalGoogle · ONSITE INTERVIEWGoogle interview questions
- Minimum Removals for Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Maximum Compatible Time WindowsIBM · OAIBM interview questions
- Task SchedulingJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions
- Minimum Markers to Clear Line SegmentsHSBC · OAHSBC interview questions