Minimum Number of Platforms Problem

Your task is to determine the minimum number of platforms required at a railway station so that no train has to wait.

Explanation:

Given two arrays:

  • AT - representing the arrival times of trains
  • DT - representing the departure times of trains.

Input:

The first line contains an integer 'T' indicating the number of test cases.
The first line of each test case has an integer 'N', the total number of trains.
The second line of each test case contains 'N' integers representing the array 'AT', which lists the arrival times of all trains.
The third line of each test case contains 'N' integers representing the array 'DT', which lists the departure times of all trains.

Output:

For each test case, return the minimum number of platforms needed such that no train has to wait.

Example:

Input:
T = 1
N = 3
AT = [900, 940, 950]
DT = [910, 1200, 1120]
Output:
2

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 50000
  • 0 <= AT[i] <= DT[i] <= 2359

Note:

  • Times are given in 24-hour format without colons. For example, 9:05 AM is represented as "905", and 9:10 PM is "2110".
  • There are no leading zeros in time representations. For example, 12:10 AM would be represented as "10", not "0010".
  • A train's departure time will always be greater than its arrival time.

Note:

You don't need to print anything; the function implementation will handle the output.
AnswerBot
4mo

Determine the minimum number of platforms needed at a railway station so that no train has to wait.

  • Sort the arrival and departure times arrays in ascending order.

  • Use two pointers to iterate through th...read more

Help your peers!
Select
Add answer anonymously...

SAP Software Developer Intern interview questions & answers

A Software Developer Intern was asked 9mo agoQ. How would you convert a byte stream to a human-readable format without using ext...read more
A Software Developer Intern was asked 9mo agoQ. Given coins with denominations 1, 2, and 5, what is the minimum number of coins ...read more
A Software Developer Intern was asked 9mo agoQ. How do you find the number of nodes in a tree, and what is the time complexity o...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked 9mo agoQ1. How would you convert a byte stream to a human-readable format without using ext...read more
A Software Developer Intern was asked 9mo agoQ2. Given coins with denominations 1, 2, and 5, what is the minimum number of coins ...read more
A Software Developer Intern was asked 9mo agoQ3. How do you find the number of nodes in a tree, and what is the time complexity o...read more
SAP Software Developer Intern 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