Code Room
CodingHardcod-g912
Subject GraphsLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You are given a list of airline tickets [from, to]. All tickets belong to a person who departs from 'JFK', and you must reconstruct the itinerary that uses every ticket exactly once. If multiple valid itineraries exist, return the one with the smallest lexical order when read as a single concatenated list of airport codes. A valid itinerary using all tickets is guaranteed to exist. Return the ordered list of airports visited.

Implement
find_itinerary(tickets: list[list[str]]) → list[str]
Examples
in[[["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]]out["JFK","MUC","LHR","SFO","SJC"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.