1class Solution:2def arrayChange(self, nums: List[int], operations: List[List[int]]) -> List[int]:3replacements = {}4for x, y in reversed(operations):5replacements[x] = replacements.get(y, y)6for idx, val in enumerate(nums):7if val in replacements:8nums[idx] = replacements[val]9return nums