FastPrepReconstruct an Itinerary
Problems/Reconstruct an Itinerary

Reconstruct an Itinerary

Meta logoMeta● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Meta E5 machine-learning engineer candidate reports an unspecified variation of the linked Reconstruct Itinerary problem in a post-phone interview loop. The precise variation was not described. This practice uses the linked public JFK start, every-ticket, lexicographic tie, and 300-ticket bounds. Source match is about 65%.

Each ticket is a directed flight [from, to]. Build an itinerary that begins at JFK and uses every ticket exactly once. Return the airports in travel order, including the starting airport. Tickets with the same endpoints are distinct and must each be used.

At least one complete itinerary is guaranteed. If several complete itineraries exist, return the lexicographically smallest airport sequence. An early alphabetical choice may lead to a dead end, so the returned route must still use every ticket.

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"]

The tickets form one complete route from JFK.

Example 2

tickets = [["JFK","SFO"],["JFK","ATL"],["SFO","ATL"],["ATL","JFK"],["ATL","SFO"]]return = ["JFK","ATL","JFK","SFO","ATL","SFO"]

Both first destinations can be completed, but starting with ATL gives the lexicographically smaller itinerary.

Example 3

tickets = [["JFK","KUL"],["JFK","NRT"],["NRT","JFK"]]return = ["JFK","NRT","JFK","KUL"]

Taking JFK → KUL first gets stuck. The complete route takes the NRT circuit before the final KUL ticket.

Constraints

  • 1 <= tickets.length <= 300
  • Each ticket has exactly two airport codes.
  • Each airport code has exactly three uppercase English letters.
  • The departure and arrival on a ticket differ.
  • A complete itinerary beginning at JFK always exists.

More Meta Onsite Interview questions

  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Reconstruct ItineraryTripjack · ONSITE INTERVIEWTripjack interview questions
  • Minimum Boards to Cover Roof HolesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Largest Island After One Land ConversionAmazon · ONSITE INTERVIEW
  • Spreadsheet Formula DependenciesAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Deepest Common Ancestors in a Multi-Parent DAGSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Reconstruct ItineraryPhonePe · ONSITE INTERVIEWPhonePe interview questions
  • Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Reconstruct ItineraryBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
  • Package Install OrderVerily · ONSITE INTERVIEW

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public List<String> findItinerary(List<List<String>> tickets) {
        // Write your code here
    }
}
Checking account…