Find Itinerary From Tickets
easy
1. You are given number N and 2*N number of strings that represent a list of N tickets(source and destination). 2. You have to find the itinerary in order using the given list of tickets. Assumption -> The input list of tickets is not cyclic and there is one ticket from every city except the final destination.
Constraints
1 <= N <= 100
Format
Input
A number N N number of lines, where each line contains 2 strings.
Output
Check the sample ouput and question video.
Example
Sample Input
4
Chennai Banglore
Bombay Delhi
Goa Chennai
Delhi Goa
Sample Output
Bombay -> Delhi -> Goa -> Chennai -> Banglore.
Question Video