NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

(This question is a variation of the LeetCode question 332. Reconstruct Itinerary. If you haven't completed that question yet, it is recommended to solve it first.)

You are given a list of airline tickets where each tickets[i] = [from_i, to_i] represents a single-use flight ticket from airport from_i to airport to_i.

Your task is to reconstruct a complete itinerary that uses every ticket exactly once. The starting airport is not provided in the input; you must deduce it from the list of tickets. If multiple valid itineraries exist, you must return the one that is lexicographically the smallest when read as a single sequence.

Test Cases
Input
Output
Expected