You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and arrival airports of one flight. Reconstruct the itinerary in order and return it.
All of the tickets must be used exactly once. The itinerary must begin with "JFK". If there are multiple valid itineraries, return the one that has the smallest lexicographic order when read as a whole.
JFK -> MUC -> LHR -> SFO -> SJC
Input: tickets = [["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]] Output: ["JFK","MUC","LHR","SFO","SJC"] Explanation: Starting from JFK, the only valid itinerary uses all 4 tickets in the order shown.
JFK --> SFO --> ATL --. ^ | | | ATL <---' ATL | | '-- SFO <-- ATL
Input: tickets = [["JFK","SFO"],["JFK","ATL"],["SFO","ATL"],["ATL","JFK"],["ATL","SFO"]] Output: ["JFK","ATL","JFK","SFO","ATL","SFO"] Explanation: ["JFK","SFO","ATL","JFK","ATL","SFO"] is also valid but lexicographically larger.
1 <= tickets.length <= 300tickets[i].length == 2fromi.length == 3toi.length == 3fromi and toi consist of uppercase English lettersfromi != toitickets = [['MUC', 'LHR'], ['JFK', 'MUC'], ['SFO', 'SJC'], ['LHR', 'SFO']]