Given a list of airline tickets as [from, to] pairs, reconstruct and return the itinerary — starting from "JFK" — that uses every ticket exactly once. If multiple valid itineraries exist, return the lexicographically smallest one.
tickets = [["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]["JFK","MUC","LHR","SFO","SJC"]Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Beyond basic traversal, some graph problems need ordering constraints (topological sort) or weighted shortest paths (Dijkstra, Bellman-Ford, minimum spanning trees).
Read the full Advanced Graphs guide →
Original problem on LeetCode ↗