X stores its data on different servers at different locations. From time to time, due to several factors, X needs to move its data from one location to another. This challenge involved keeping track of the locations of X's data and report them at the end of the year.
At the start of the year, X's data was located at n different locations. Over the course of the year, X'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 :
Returns
int[]: the locations storing data after all moves are made, in ascending order.
Examples
01 · Example 1
locations = [1, 7, 6, 8] movedFrom = [1, 7, 2] movedTo = [2, 9, 5] return = [5, 6, 8, 9]
Data begins at locations listed in locations. Over the course of the year, the data was moved three times.
Data was first moved from movedFrom[0] to movedTo[0], from 1 to 2. Next, it is moved from 7 to 9, and finally from location 2 to 5.
In the end, the locations where data is present are [5,6,8,9] in ascending order.
02 · Example 2
locations = [1, 5, 2, 6] movedFrom = [1, 4, 5, 7] movedTo = [4, 7, 1, 3] return = [1, 2, 3, 6]

(ignore the typo in the img)
The operations should be in order.
For example, 5 is in the output because the 1st operation moved data from 1->2.
Then in the following operation (3rd), the data is moved from 2->5
。゚•┈ 🌷, ᥫ᭡ Credit to ꒰ა Edward ໒꒱┈• 。゚
03 · Example 3
locations = [1, 2, 3] movedFrom = [1, 2] movedTo = [5, 6] return = [3, 5, 6]
N/A (This example is a sample test case :)
Constraints
N/A (If you know about it, feel free to contact us. THX!More Amazon problems
- Closest Version DateONSITE INTERVIEW · Seen Jul 2026
- Maximum Concurrent Processes (Bar Raiser Round)ONSITE INTERVIEW · Seen Jul 2026
- Maximum Product New RatingOA · Seen Jul 2026
- Permutation SorterOA · Seen Jul 2026
- Get Distinct Pairs (Also apply to AS intern)Seen Jul 2026
- Maximum Final ValueSeen Jul 2026
- Minimum Delivery Center InconvenienceOA · Seen Jun 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Jun 2026
public int[] locationOfDataAfterTransfers(int[] locations, int[]movedFrom, int[]movedTo) {
// write your code here
}
locations[1, 7, 6, 8]
movedFrom[1, 7, 2]
movedTo[2, 9, 5]
expected[5, 6, 8, 9]
checking account