Reach a Destination Through Scheduled Flights
Problem statement
There are airportCount airports numbered from 0 through airportCount - 1. Each flight is [origin, destination, departureTime, arrivalTime].
You begin at startAirport at time 0. You may take a flight from your current airport when its departure time is at least your current arrival time. After taking it, your current time becomes its arrival time.
Examples
Example 1
airportCount = 3flights = [[0,1,2,5],[1,2,5,8]]startAirport = 0targetAirport = 2return = trueTake the first flight and arrive at airport 1 at time 5. The second flight departs exactly at time 5, so the connection is valid.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.