Reconstruct Itinerary
Try to solve the Reconstruct Itinerary problem.
We'll cover the following
Statement
Given a list of airline tickets
 where tickets[i] = [from
i
, to
i
]
 represent a departure airport and an arrival airport of a single flight, reconstruct the itinerary in the correct order and return it.
The person who owns these tickets
always starts their journey from "JFK"
. Therefore, the itinerary must begin with "JFK"
. If there are multiple valid itineraries, you should prioritize the one with the smallest
For example, the itineraryÂ
["JFK", "EDU"]
 has a smaller lexical order thanÂ["JFK", "EDX"]
.
Note: You may assume all tickets form at least one valid itinerary. You must use all the tickets exactly once.
Constraints:
tickets.length
tickets[i].length
from
i
.length
to
i
.length
from
i
to
i
from
i
 andÂto
i
 consist of uppercase English letters.
Example
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.