Bird
Raised Fist0

Using the sweep line algorithm, what is the minimum number of platforms required for arrivals = [1000] and departures = [1000]?

medium🧾 Code Trace Q4 of Q15
Intervals - Minimum Number of Platforms Required
Using the sweep line algorithm, what is the minimum number of platforms required for arrivals = [1000] and departures = [1000]?
A0
B2
C1
DCannot determine
Step-by-Step Solution
Solution:
  1. Step 1: Create and sort events

    Events: (1000, -1) departure first, then (1000, 1) arrival due to sorting rule.
  2. Step 2: Sweep line count

    Count platforms: at 1000 departure -> platforms_needed = -1, then arrival -> platforms_needed = 0. Max platforms recorded is 1.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Departure before arrival at same time avoids overcounting [OK]
Quick Trick: Departure before arrival at same time -> no extra platform [OK]
Common Mistakes:
MISTAKES
  • Counting arrival before departure at same time, resulting in 2 platforms
Trap Explanation:
PITFALL
  • Candidates often count arrival before departure at same time, inflating platform count.
Interviewer Note:
CONTEXT
  • Tests handling of edge cases with simultaneous arrival and departure.
Master "Minimum Number of Platforms Required" in Intervals

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 Intervals Quizzes