Minimum buses to run a timetable

0
Remix

A bus depot has a timetable of trips, each with a departure time and an arrival time. A bus can take a new trip once it has arrived from its previous one. Return the fewest buses needed to run every trip (a meeting-rooms style problem).

Follow-up: each trip now also has a departure station and an arrival station, and a bus can only take a trip that leaves from the station where it currently is. Find the fewest buses again. Aim for a heap-based solution rather than scanning every bus.

SnowflakeTechnical phone screenLast asked Sep 2026
No answer yet. Write the first one; the best answer gets endorsed.