Reconstruct Itinerary
You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

30:00

Reconstruct Itinerary
hard
Topics
Companies

You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

Example 1:
Input: [["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]
Output: ["JFK","MUC","LHR","SFO","SJC"]
Constraints:
  • 1tickets.length3001 \leq \text{tickets.length} \leq 300

  • tickets[i].length==2\text{tickets}[i].\text{length} == 2

  • fromi,toi\text{from}_i, \text{to}_i consist of uppercase English letters.

  • fromi.length==toi.length==3\text{from}_i.\text{length} == \text{to}_i.\text{length} == 3

  • fromitoi\text{from}_i \neq \text{to}_i

Input
arr =[["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]

Start

JFK

LHR

MUC

SFO

SJC

Variables
No variables to display
DepthFunction Call
Stack empty
0/15