2295. Replace Elements in an Array

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2295

class Solution:
    def arrayChange(self, nums: List[int], operations: List[List[int]]) -> List[int]:
        d = {v: i for i, v in enumerate(nums)}
        for a, b in operations:
            nums[d[a]] = b
            d[b] = d[a]
        return nums