Question-1
Amazon stores its data on different servers at different locations. From time to time, due to several factors, Amazon needs to move its data from one location to another. This challenge involved keeping track of the locations of Amazon's data and report them at the end of the year.
At the start of the year, Amazon's data was located at n
different locations. Over the course of the year, Amazon's data was moved from one server to another m
times. Precisely, in the ith operation, the data was moved from movedFrom[i]
to movedTo[i]
. Find the locations of the data after all m
moving operations. Return the locations in ascending order.
Note: It is guaranteed that for any movement of data: 4
There is data at movedFrom[i]
.
There is no data at movedTo[i]
.
Example
locations = [1, 5, 2, 6]
movedFrom = [1, 4, 5, 7]
movedTo = [4, 7, 1,3]
output = [1, 2, 3, 6]