Answer: Samsung Electronics Hiring Challenge | On-Campus OA (2021)

Answer · Posted Jun 2026

Approach Sort both arrival and departure arrays. Use two pointers: One pointer for arrivals. One pointer for departures. If the next train arrives before or at the departure of the current train, an additional platform is required. Otherwise, one platform becomes free. Track the maximum number of platforms required at any point. Strategy Sort arrival times. Sort departure times. Initialize: platforms = 1 maxPlatforms = 1 Traverse both arrays using two pointers. Update the maximum platforms required. Return the answer. ...

The full answer & interview discussion are available to premium members.

Log in Create a free account