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...

Morgan Stanley Digital Technology Intern interview questions & answers

A Digital Technology Intern was asked Q. Boundary Traversal of a Binary Tree Given a binary tree of integers, your task i...read more
A Digital Technology Intern was asked Q. Minimum Number of Platforms Problem Your task is to determine the minimum number...read more
A Digital Technology Intern was asked Q. Next Greater Number Problem Statement Given a string S which represents a number...read more

Popular interview questions of Digital Technology Intern

A Digital Technology Intern was asked Q1. Boundary Traversal of a Binary Tree Given a binary tree of integers, your task i...read more
A Digital Technology Intern was asked Q2. Minimum Number of Platforms Problem Your task is to determine the minimum number...read more
A Digital Technology Intern was asked Q3. Next Greater Number Problem Statement Given a string S which represents a number...read more
Morgan Stanley Digital Technology 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