Given arrival and departure times of N trains that reach a railway station, for a given k
platforms, return the maximum number of trains that we can house on the k
platforms.
k <<< N
Arrival and departure time Array
Input: arr[] = {9:00, 9:40, 9:50, 11:00, 15:00, 18:00}
dep[] = {9:10, 12:00, 11:20, 11:30, 19:00, 20:00}
This question was asked of me in some interview, so what is best algorithm for that? This question is slightly modified from this question.
I tried greedy algorithm for this question but it is not working for all test cases. For eg:for k=2 We are given time intervals
arr[]={1:00,1:30,2:00}
dept[]={1:40,2:10,3:30}
' be removing the {1:30 and 2:10 interval we can do the task for k=2 {1:00-1:40} and {2:00-3:30} as no other train occurs between this time