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 involves keeping track of the locations of Amazon's data and reporting 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:
- There is data at
movedFrom[i]. - There is no data at
movedTo[i].
Complete the function getFinalLocations in the editor.
The function is expected to return an INTEGER_ARRAY.
The function accepts the following parameters:
INTEGER_ARRAY locationsINTEGER_ARRAY movedFromINTEGER_ARRAY movedTo
locations = [1, 7, 6, 8] movedFrom = [1, 7, 2] movedTo = [2, 9, 5] return = [5, 6, 8, 9]

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, data was 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.- Minimum Operations to Make the Integer ZeroSeen Jun 2026
- Create Array Generator ServiceSeen Jun 2026
- Minimum Merge ConflictsOA · Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Drone Delivery RouteOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Minimum Operations to Make Array ValidOA · Seen Jun 2026
- Sort Bug Report FrequenciesOA · Seen Jun 2026
public List<Integer> getFinalLocations(List<Integer> locations, List<Integer> movedFrom, List<Integer> movedTo) {
// write your code here
}