#3810

Minimum Operations to Reach Target Array

specialist · 680 · lc medium +30 · 63.3% accepted · 57 likes · top 66%

Description

Given two integer arrays nums and target of length n, in each operation choose a value x, locate all maximal contiguous runs of x in nums, and simultaneously overwrite each such run's positions with the corresponding values from target; return the minimum number of operations needed to transform nums into target.

Code

1
2
3