Uber Technical Video Screen
Very similar to https://leetcode.com/problems/reconstruct-itinerary/ but the origin is not provided. We should find the origin, assuming there exists a valid origin and output the complete route .
Follow up - What if multiple routes are available and output the longest route possible.
[["JFK","SFO"],["ATL","CDG"],["SFO","ATL"],["CDG","MAA"],["MAA","ORD"],["ORD","DFW"],["CDG","DXB"]]
Valid routes -
JFK - SFO - ATL - CDG - MAA - ORD - DFW
JFK - SFO - ATL - CDG - DXB
Output should be JFK - SFO - ATL - CDG - MAA - ORD - DFW