Minimum Number of Platforms Required

You are provided with two arrays, AT and DT, representing the arrival and departure times of all trains arriving at a railway station.

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

Example:

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

Explanation:

The first train departs at 910. The second train arrives shortly after at 940 and will need a new platform. The third train arrives at 950 while the second is still stationed, necessitating a total of 2 platforms.

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 50000
  • 0 <= AT[i] <= DT[i] <= 2359
  • Time is given in 24H format, without colons

Note:

No need to print the output, just implement the function to return the required result. Consider solving the problem in O(N) time and O(1) space if possible.

AnswerBot
1y

This question asks to find the minimum number of platforms required at a railway station so that no train needs to wait.

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

  • Initialize a vari...read more

Help your peers!
Select
Add answer anonymously...

Paytm Software Developer interview questions & answers

A Software Developer was asked 4mo agoQ. Given a sorted array of integers nums and an integer target, write a function to...read more
A Software Developer was asked 6mo agoQ. What is multithreading?
A Software Developer was asked 7mo agoQ. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more

Popular interview questions of Software Developer

A Software Developer was asked 7mo agoQ1. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
A Software Developer was asked 8mo agoQ2. Given a binary tree, return the vertical order traversal of its nodes' values. (...read more
A Software Developer was asked 9mo agoQ3. Given a graph and a source node, find the shortest path from the source to all o...read more
Paytm 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