Find Itinerary from a given list of tickets.

Problem:

Find Itinerary from a given list of tickets.
Given a list of tickets, find itinerary in order using the given list.

Example:
Input:
“Chennai” -> “Banglore”
“Bombay” -> “Delhi”
“Goa” -> “Chennai”
“Delhi” -> “Goa”

Output:
Bombay->Delhi, Delhi->Goa, Goa->Chennai, Chennai->Banglore,

It may be assumed that the input list of tickets is not cyclic and there is one ticket from every city except final destination.

Solution:

– One solution is Topological Sorting
– Another is iteration over hash map (hint reverse of map to get starting point)

Latest Source Code:
Github: ItineraryFinder.java


Output:

 Bombay -> Delhi -> Goa -> Chennai -> Banglore
Author: Hrishikesh Mishra