Minimum Number of Platforms Needed Problem Statement
You are given the arrival and departure times of N trains at a railway station for a particular day. Your task is to determine the minimum number of platforms required so that no train has to wait, meaning that every arriving train has an available platform immediately.
Input:
The input begins with a single integer T, representing the number of test cases. Each test case consists of:
- A line with a positive integer N, the number of trains.
- A line containing N integers, the arrival times of the trains in HHMM format.
- A line containing N integers, the departure times of the trains in HHMM format.
Output:
For each test case, return the minimum number of platforms needed at the railway station.
Example:
Input:
T = 1
N = 3
Arrivals = [900, 940, 950]
Departures = [910, 1200, 1120]
Output:
2
Explanation:
In the given example, between 940 and 950, you have two overlapping schedules which require two platforms.
Constraints:
1 <= T <= 100
1 <= N <= 1000
0 <= arrival[i] <= departure[i] <= 2359
- Time representation is in HHMM format.
Note:
Do not print anything. It has been already taken care of.
Rani
5mo
student at
REVA Institute of Technology and Management, Bangalore
Explanation
Rani
5mo
student at
REVA Institute of Technology and Management, Bangalore
Time
UREVENUKA SHIVAJI
5mo
Space complexity:o1 explanation:time complexity:o(1) explanation
avinash verma
7mo
Space Complexity: O(1)Explanation: Time Complexity: O(1)Explanation
Sweet Swathi
1y
Space Complexity: O(1)Explanation: Time Complexity: O(1)Explanation:
kalpam kavya
2y
Space complexity:o(1) Explanation:Ti me complexity:o(1) Explanation:
Add answer anonymously...
Top Amazon Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Amazon Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app