Given arrival and departure times of all trains that reach a railway station, find the minimum number of platforms required for the railway station so that no train waits.
Consider that all the trains arrive on the same day and leave on the same day. Arrival and departure time can never be the same for a train but we can have arrival time of one train equal to departure time of the other. At any given instance of time, same platform can not be used for both departure of a train and arrival of another train. In such cases, we need different platforms.
First line of the input file contains t , the total number of test cases.
For each test case:
First line contains n, the total number of trains.
Second line contains n arrival times for n trains, where ith arrival time arrival[i] is for the ith train
Third line contains n departure times for n trains, where ith departure time departure[i] is for the ith train
Note: Time intervals are in the 24-hour format (HHMM) , where the first two characters represent hour (between 00 to 23 ) and the last two characters represent minutes (between 00 to 59).
For each test case you need to print a single integer containing the number of minimum platforms required at the railway station such that no train waits.
1<= t <=2000
2<= n <=1440
0000 <= arrival[i],departure[i] <= 2399
Test Case 1:
There are 2 trains.
Arrival | Departure | |
Train 1 | 0032 | 1031 |
Train 2 | 0414 | 0959 |
Here Train 2 arrives before Train 1 leaves.So 2 platforms will be used simultaneously at max
Test Case 2:
Arrival | Departure | |
Train 1 | 0219 | 0954 |
Train 2 | 0255 | 0355 |
Train 3 | 0051 | 1049 |
Train 4 | 0449 | 0633 |
First Train 3 arrives.Then Train 1 and Train 2 arrive. No train has left yet.So max platforms being used is 3.Then train 2 leaves.So 1 platform is free.Next train 4 arrives. So max platforms is still 3.Then Train 4,Train 1 and Train 3 leave