Bird
Raised Fist0

Consider the min-heap approach for minimum platforms. What is the output when arrivals = [1000] and departures = [1000] (a single train arriving and departing at the same time)?

medium🧾 Code Trace Q4 of Q15
Greedy Algorithms - Minimum Platforms (Train Stations)
Consider the min-heap approach for minimum platforms. What is the output when arrivals = [1000] and departures = [1000] (a single train arriving and departing at the same time)?
A0
Bnull (error)
C2
D1
Step-by-Step Solution
Solution:
  1. Step 1: Process single train arrival and departure

    Heap is empty initially. Arrival=1000, no trains to pop. Push departure=1000. Heap size=1.
  2. Step 2: Max platforms updated to 1

    Return max_platforms=1.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Single train requires one platform [OK]
Quick Trick: Single train always needs one platform [OK]
Common Mistakes:
MISTAKES
  • Assuming 0 platforms if arrival=departure
  • Confusing <= with < in heap pop condition
  • Expecting error on equal times
Trap Explanation:
PITFALL
  • Candidates often think arrival == departure means no platform needed or causes error, but one platform is required.
Interviewer Note:
CONTEXT
  • Tests handling of edge cases with equal arrival and departure times.
Master "Minimum Platforms (Train Stations)" in Greedy Algorithms

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Greedy Algorithms Quizzes