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.
AnswerBot
4mo

Determine the minimum number of platforms needed at a railway station based on arrival and departure times of trains.

  • Sort the arrival and departure times in ascending order.

  • Use two pointers to keep tr...read more

Rani
10mo
student at
REVA Institute of Technology and Management, Bangalore
Explanation
Rani
10mo
student at
REVA Institute of Technology and Management, Bangalore
Time
UREVENUKA SHIVAJI
11mo
Space complexity:o1 explanation:time complexity:o(1) explanation
avinash verma
1y
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:

Select
Add answer anonymously...

Amazon Software Developer interview questions & answers

A Software Developer was asked 1mo agoQ. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ. What is MySQL?
A Software Developer was asked 1mo agoQ. What is Java?

Popular interview questions of Software Developer

A Software Developer was asked 1mo agoQ1. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ2. What is MySQL?
A Software Developer was asked 1mo agoQ3. What is Java?

Top HR questions asked in Amazon Software Developer

A Software Developer was asked 1mo agoQ1. Tell me about a time you had to get to the root cause of a problem
A Software Developer was asked 5mo agoQ2. What are the short-term and long-term goals for the team or organization?
A Software Developer was asked 5mo agoQ3. Why do you want to work at Amazon?
Amazon Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits