Skip to content

Problem 3: Maximum platforms needed

Course: Intro Class 2- DSA - chapter 7

Problem Link: https://www.geeksforgeeks.org/minimum-number-platforms-required-railwaybus-station/

Same as previous problem. We will use the handling ranges using prefix sum and frequency array technique.

Create a frequency array for all possible times. Fill it up by calculating gain[] and then doing prefix sum to get actual frequency

The maximum value of frequency is the minimum number of platforms needed. Why? Because for any time, at max these number of trains can be at the station and no 2 trains can be in same platform at same time.