Back to problems

Minimum Steps to Reorder Layers

Algorithm · Expedia · Hard

You have two integer arrays, current and desired, each containing the same n distinct neural network layers in some order. Beginning with current, you may apply this move any number of times: take the final layer out of the array and place it at any location within the shorter array, including either end. Determine the smallest number of moves needed to change current into desired. It is guaranteed that desired can be obtained from current. Constraints 1 ≤ n ≤ 2 × 10 5…

Checking your access…