FastPrepReconstruct Itinerary
Problems/Reconstruct Itinerary

Reconstruct Itinerary

PhonePe logoPhonePe● HardONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a real PhonePe onsite interview report. The report linked the exact Reconstruct Itinerary task, but it did not reproduce the rules, function interface, examples, or constraints. The core task match is about 95%.

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 PhonePe interview questions

  • Maximum Sum with K-Element SkippingONSITE INTERVIEW · Seen Dec 2026
  • Minimum Number of Days to Make m BouquetsONSITE INTERVIEW · Seen Dec 2026
  • Evaluate DivisionONSITE INTERVIEW · Seen Oct 2026
  • K-th Smallest Value in a Sorted MatrixONSITE INTERVIEW · Seen Oct 2026
  • Identify Two Failing Tests From an Oracle TranscriptONSITE INTERVIEW · Seen Sep 2026
  • Count Bowl SubarraysONSITE INTERVIEW · Seen Jul 2026
  • Constrained Jump SequencesOA · Seen Aug 2026
  • Maximum Payout with Context SwitchesOA · Seen Aug 2026
  • Substrings Without a Target SubsequenceOA · Seen Aug 2026
  • Luna and the Colorful SocksOA · Seen Jul 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
  • Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Making a Large IslandMeta · ONSITE INTERVIEWMeta interview questions
  • Reconstruct ItineraryBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
  • Package Install OrderVerily · ONSITE INTERVIEW
All PhonePe interview questionsSee PhonePe hiring insights
Saved
class Solution {
    public List<String> findItinerary(List<List<String>> tickets) {
      // write your code here
    }
}
Checking account…