← 返回 netflix 的题目列表Reconstruct Itinerary Variation
类型:online_judge
Given a set of flight routes, find an itinerary starting from a specific city that visits all cities with the smallest lexicographical order possible, traveling each city at most once. Then, solve the follow-up: print all possible itinerary paths.
Input Format:
Several flight routes provided as a 2D array, each element contains two strings representing the start and end cities
The name of the starting city as a string
Output Format:
Return a list containing the itinerary path in lexicographical order, and all possible itineraries.
Example:
Input: [['JFK', 'SFO'], ['JFK', 'ATL'], ...], 'JFK'
Output: ['JFK', 'ATL', '...'] and all possible itineraries
Constraints:
Number of flights is in the range [1, 1000]
Number of cities is in the range [1, 100]
Example
Input
[['JFK', 'SFO'], ['JFK', 'ATL'], ['ATL', 'JFK']]