Reconstruct Itinerary
Updated
Problem statement
You are given airline tickets represented as [from, to] pairs. Reconstruct the itinerary that uses every ticket exactly once.
The itinerary must start at "JFK". If multiple valid itineraries exist, return the lexicographically smallest itinerary when read as a single sequence of airport codes.
Function
findItinerary(tickets: List<List<String>>) → List<String>Examples
Example 1
tickets = [["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]return = ["JFK","MUC","LHR","SFO","SJC"]There is only one route that uses all tickets from JFK.
Example 2
tickets = [["JFK","SFO"],["JFK","ATL"],["SFO","ATL"],["ATL","JFK"],["ATL","SFO"]]return = ["JFK","ATL","JFK","SFO","ATL","SFO"]Both choices from JFK can lead to valid routes, but the route beginning with ATL is lexicographically smaller.
Constraints
1 <= tickets.length <= 300.tickets[i].length == 2.- Each airport code has 1 to 3 uppercase English letters.
- The departure and arrival on a ticket differ.
- A complete itinerary that starts at
"JFK"and uses every ticket always exists.
More Bloomberg LP Phone Screen questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Periodic-Color Binary Forest RootsGoogle · PHONE SCREENGoogle interview questions
- Find Trapped ZonesServiceNow · PHONE SCREENServiceNow interview questions
- Reconstruct ItineraryTripjack · ONSITE INTERVIEWTripjack interview questions
- Visit Desired Attractions Without Reusing a TrailDuolingo · PHONE SCREENDuolingo interview questions
- Attraction Route Without Reusing TrailsWhatNot · PHONE SCREENWhatNot interview questions
- Spreadsheet With Dependent CellsCharacter.AI · PHONE SCREEN
- Largest Island After One Land ConversionAmazon · ONSITE INTERVIEW
- Evaluate Live Spreadsheet ExpressionsStrala · PHONE SCREEN
- Enumerate Directed Paths and CyclesByteDance · PHONE SCREENByteDance interview questions
- Process Graph Rule ValidationHadrian · PHONE SCREENHadrian interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)