• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 21, 2022 |4.2K Views
Find Itinerary from a given list of tickets (Tickets Hashing)
  Share  1 Like
Description
Discussion

1) Create a HashMap of given pair of tickets. Let the created HashMap be 'dataset'. Every entry of 'dataset' is of the form "from->to" like "Chennai" -> "Banglore" 2) Find the starting point of itinerary. a) Create a reverse HashMap. Let the reverse be 'reverseMap' Entries of 'reverseMap' are of the form "to->form". Following is 'reverseMap' for above example. "Banglore"-> "Chennai" "Delhi" -> "Bombay" "Chennai" -> "Goa" "Goa" -> "Delhi" Find Itinerary from a given list of tickets (Tickets Hashing) : https://www.geeksforgeeks.org/find-itinerary-from-a-given-list-of-tickets/