Minimum Number of Platforms Required
You are provided with two arrays, AT
and DT
, representing the arrival and departure times of all trains arriving at a railway station.
Your task is to determine the minimum number of platforms needed at the railway station so that no train has to wait.
Example:
Input:
T = 1
N = 3
AT = [900, 940, 950]
DT = [910, 1200, 1120]
Output:
2
Explanation:
The first train departs at 910. The second train arrives shortly after at 940 and will need a new platform. The third train arrives at 950 while the second is still stationed, necessitating a total of 2 platforms.
Constraints:
- 1 <= T <= 10
- 1 <= N <= 50000
- 0 <= AT[i] <= DT[i] <= 2359
- Time is given in 24H format, without colons
Note:
No need to print the output, just implement the function to return the required result. Consider solving the problem in O(N) time and O(1) space if possible.

This question asks to find the minimum number of platforms required at a railway station so that no train needs to wait.
Sort the arrival and departure times arrays in ascending order.
Initialize a vari...read more
Paytm Software Developer interview questions & answers
Popular interview questions of Software Developer


Reviews
Interviews
Salaries
Users

