Minimum Number of Platform Needed

You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no train waits i.e No train should wait for the platform to be clear or free.

Input Format :

The first line of input contains a single integer T, representing the number of test cases or queries to be run. 
Then the T test cases follow.

The first line of each test case contains a positive integer N which represents the number of trains that arrive at the railway station in a day.

The Second line of each test case contains N integers denoting the arrival time of all the trains.

The third line of each test case contains N integers denoting the departure time of all the trains.
Output Format :
For each test case, return the minimum number of platforms required at the railway station such that no train waits.
Note :
Representation of arrival and departure time will be in HHMM format.

Do not print anything. It has been already taken care of.
Constraints :
1 <= T <=100
1 <= N <=1000
0 <= arrival[i] <= departure[i] <= 2359

Time Limit: 1 sec
CodingNinjas
author
2y

I was aware of this type of problem, so solved it with the mentioned optimal solution in a first go.

CodingNinjas
author
2y
Space Complexity: O(1)Explanation: Time Complexity: O(1)Explanation:
CodingNinjas
author
2y
Space Complexity: O(1)Explanation: Time Complexity: O(1)Explanation:
Rani
4mo
student at
REVA Institute of Technology and Management, Bangalore
Explanation
Rani
4mo
student at
REVA Institute of Technology and Management, Bangalore
Time
UREVENUKA SHIVAJI
5mo
Space complexity:o1 explanation:time complexity:o(1) explanation
avinash verma
6mo
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...
Amazon Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter