passes[i] = [from, to] is one flight from airport from to airport to; airports are written as three-letter codes.
The trip started at "JFK", and every pass was flown exactly once. Rebuild the trip: return the list of airports in the order they were visited, starting with "JFK".
If several routes fit, return the one that comes first alphabetically when the lists are compared airport by airport from the left (for example, ["JFK", "AMS"] comes before ["JFK", "ATH"]).
At least one route using all the passes is guaranteed to exist.passes=[['OSL', 'RIX'], ['JFK', 'DUB'], ['DUB', 'OSL']] → ['JFK', 'DUB', 'OSL', 'RIX']
From JFK the only pass goes to DUB, then on to OSL and finally RIX. There is only one possible route.
passes=[['JFK', 'LIS'], ['JFK', 'CPH'], ['CPH', 'JFK'], ['LIS', 'CPH']] → ['JFK', 'CPH', 'JFK', 'LIS', 'CPH']
Two routes work: JFK, CPH, JFK, LIS, CPH and JFK, LIS, CPH, JFK, CPH. The first comes earlier alphabetically, since CPH < LIS at the second stop.
passes=[['JFK', 'AMS']] → ['JFK', 'AMS']
from and to are exactly 3 uppercase English letters"JFK" using every pass existspasses=[['OSL', 'RIX'], ['JFK', 'DUB'], ['DUB', 'OSL']]
['JFK', 'DUB', 'OSL', 'RIX']
Run checks the first 3 tests in your browser. Submit checks all 63 tests on the server, hidden ones included.