Twilio | Onsite | Possible Routes
Anonymous User
903
There exist six airports identified by codes { SFO, YYZ, ORD, DFW, JFK, PVR }. 
There exist a number of flights between airports as follows
SFO -> PVR 
SFO -> ORD 
ORD -> DFW 
DFW -> JFK 
SFO -> YYZ
YYZ -> JFK
The above flights are uni-directional (one-way). 
Given two airports, (SFO, JFK), can one fly from one to the other given available flights? 

Try the following inputs: 
1) SFO to JFK ? 
(answer = Yes) :: there are two possible routes: (SFO - YYZ - JFK) or (SFO - ORD - DFW - JFK) 
2) JFK to PVR ? 
(answer = No)
Comments (2)