PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Pinterest

Reconstruct itinerary with lexicographic ties

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to model and traverse directed graphs with repeated edges, enforce lexicographic ordering among possible paths, and analyze time and space complexity for an algorithmic solution.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Software Engineer

Reconstruct itinerary with lexicographic ties

Company: Pinterest

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given m airline tickets as directed pairs [from, to]. Build an itinerary that starts at a specified airport start (e.g., "JFK") and uses every ticket exactly once. If multiple itineraries are possible, return the lexicographically smallest sequence of airport codes. Tickets may repeat; m can be up to 10^4. Implement the function to return the itinerary, describe your data structures, analyze time and space complexity, and explain how your approach handles cycles and cases where no valid itinerary exists.

Quick Answer: This question evaluates a candidate's ability to model and traverse directed graphs with repeated edges, enforce lexicographic ordering among possible paths, and analyze time and space complexity for an algorithmic solution.

Related Interview Questions

  • Maximize Boxes Stored Through One Entrance - Pinterest (medium)
  • Solve Multiple Coding Interview Problems - Pinterest (medium)
  • Implement a Sparse Matrix Class - Pinterest (medium)
  • Assign Pins to Shortest Columns - Pinterest (medium)
  • Design Hierarchical Permission Checks - Pinterest (medium)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
9
0

You are given m airline tickets as directed pairs [from, to]. Build an itinerary that starts at a specified airport start (e.g., "JFK") and uses every ticket exactly once. If multiple itineraries are possible, return the lexicographically smallest sequence of airport codes. Tickets may repeat; m can be up to 10^4. Implement the function to return the itinerary, describe your data structures, analyze time and space complexity, and explain how your approach handles cycles and cases where no valid itinerary exists.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Pinterest•More Software Engineer•Pinterest Software Engineer•Pinterest Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.