Minimum Train Platforms

Problem Given train arrival and departure times at a station, find the minimum number of platforms so that no train waits (equivalently: max number of overlapping intervals at any moment).

Input / Output

  • Input: arrays arr[] and dep[] of times (interval i = [arr[i], dep[i]]).
  • Output: minimum platform count.

Constraints

  • Up to 10^5 trains; O(n log n) expected. Clarify whether arrival exactly at another's departure shares a platform.

Example

  • arr = [900, 940, 950, 1100, 1500, 1800], dep = [910, 1200, 1120, 1130, 1900, 2000] → 3.
asked …
LeaderboardSalaryAccount