Back to problems

Find Round-Trip Flight Itineraries

Algorithm · Expedia · Medium

Given a list of directed flights and a starting airport, discover every possible round-trip journey that begins at the origin, travels through a sequence of distinct airports, and comes back to the origin. Each flight is represented as a pair [from, to] indicating a direct connection from the first airport to the second. An itinerary is a sequence of airport codes where: The first and last codes are both the origin. No airport appears twice except the origin, which only…

Checking your access…