Company: Paypal_25dec
Difficulty: medium
Reconstruct Traveler's Journey Problem Description A traveler visited a series of unique landmarks on a journey. Unfortunately, their travel journal was damaged, and they can no longer remember the exact order of their visits. However, they do have a collection of photos, each showing exactly two landmarks that were visited consecutively (either landmark could have been visited first). Given the collection of photos represented as pairs of landmark IDs in travelPhotos , help the traveler reconstruct the complete journey. Each landmark was visited exactly once, and for every consecutive pair of landmarks in the journey, there exists a photo containing both landmarks. You may reconstruct the journey in either forward or reverse order - both are considered correct. Example For travelPhotos = [[3, 5], [1, 4], [2, 4], [1, 5]] , the output can be solution(travelPhotos) = [3, 5, 1, 4, 2] . Explanation: The photos show that landmarks 3 and 5 were visited consecutively, as were 1 and 4, 2 and 4