Reconstruct Itinerary
A hard-tier problem at 44% community acceptance, tagged with Depth-First Search, Graph, Eulerian Circuit. Reported in interviews at Pinterest and 8 others.
You've got tickets scattered across airports and one of them is marked as the starting point. You need to use every single ticket in order and return the itinerary. Pinterest, Netflix, Booking.com, and Uber all ask this. The acceptance rate sits at 44%, which means most candidates either get stuck on the graph construction or don't recognize the Eulerian Circuit pattern hiding inside. This isn't a simple DFS problem. If you hit it on your OA and blank on the trick, StealthCoder surfaces the working solution in seconds, invisible to the proctor.
Companies that ask "Reconstruct Itinerary"
Reconstruct Itinerary is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe trap is treating this like a standard traversal. You build a directed graph where airports are nodes and tickets are edges, then find a path that uses every edge exactly once. That's an Eulerian circuit, and the key is Hierholzer's algorithm with DFS. You need an ordered adjacency list (usually a min-heap or sorted list to get lexicographically smallest result), a visited edge counter, and the discipline to build the path in reverse as you pop from the stack. Most people either skip the sorting, lose track of which edges they've used, or return the path in the wrong order. The graph construction itself is deceptively simple, but the traversal order and backtracking discipline separate solvers from blankers. When the obvious greedy DFS fails to include all tickets, you're staring at why this problem exists.
Pattern tags
You know the problem.
Make sure you actually pass it.
Reconstruct Itinerary recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reconstruct Itinerary interview FAQ
Is this really just a DFS problem?+
No. It's a DFS implementation of Hierholzer's algorithm for finding Eulerian paths. Standard DFS doesn't guarantee you use every edge exactly once. You need to track visited edges and build the result in reverse as you backtrack. Miss that nuance and your solution looks right but fails on multi-edge test cases.
Why does sorting the adjacency list matter?+
The problem asks for the lexicographically smallest valid itinerary. If you don't sort destinations alphabetically before traversal, you'll find a valid path but not the correct one. Most implementations use a min-heap or sorted list to guarantee you explore destinations in order.
What's the actual trick if my DFS gets stuck?+
You're probably visiting a node and not backtracking properly when you hit a dead end. Hierholzer's algorithm builds the path in reverse: append nodes to the result after exploring all outgoing edges, not before. This ensures you find the cycle that uses every edge.
How do companies like Netflix and Uber actually use this pattern?+
This problem models route planning and resource optimization. Any system that needs to traverse all connections exactly once (delivery routes, connection scheduling, network paths) maps to Eulerian circuits. It's not hypothetical; it's infrastructure.
Will drilling other graph problems prepare me for this?+
Standard graph problems won't teach you Eulerian circuits unless you specifically study them. Generic DFS and BFS fail here. You need to recognize the pattern: 'use every edge exactly once.' If you haven't seen Hierholzer's algorithm, you'll need to learn it or lean on your assessment tools.
Want the actual problem statement? View "Reconstruct Itinerary" on LeetCode →