Minimum Platforms
Submissions: 58449   Accuracy:


  Difficulty: Medium   Marks: 4

Given arrival and departure times of all trains that reach a railway station. Your task is to find the minimum number of platforms required for the railway station so that no train waits.
Note: Consider that all the trains arrive on the same day and leave on the same day. Also, arrival and departure times must not be same for a train.

The first line of input contains T, the number of test cases. For each test case, first line will contain an integer N, the number of trains. Next two lines will consist of N space separated time intervals denoting arrival and departure times respectively.
Note: Time intervals are in the 24-hour format(
hhmm), preceding zeros are insignificant. 200 means 2:00.
Consider the example for better understanding of input.

For each test case, print the minimum number of platforms required
for the trains to arrive and depart safely.

1 <= T <= 100
1 <= N <= 1000
1 <= A[i] < D[i] <= 2359


900  940 950  1100 1500 1800
910 1200 1120 1130 1900 2000


Testcase 1: Minimum 3 platforms are required to safely arrive and depart all trains.

** For More Input/Output Examples Use 'Expected Output' option **

Author: shubhamdhingra77

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.