Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Transform Array

Try to solve the Minimum Operations to Transform Array problem.

Statement

You are given two integer arrays nums1 of length n and nums2 of length n +1+ 1.

In one operation, you can perform either of the following actions:

  • Choose any element in nums1 and increase or decrease its value by 11.

  • Choose any element in nums1 and append a copy of it to the end of nums1.

Return the minimum number of operations required to make nums1 identical to nums2.

Constraints:

  • 1≤1 \leq n ==== nums1.length ≤105\leq 10^5

  • nums2.length ==== n +1+ 1

  • 1≤1 \leq nums1[i], nums2[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Transform Array

Try to solve the Minimum Operations to Transform Array problem.

Statement

You are given two integer arrays nums1 of length n and nums2 of length n +1+ 1.

In one operation, you can perform either of the following actions:

  • Choose any element in nums1 and increase or decrease its value by 11.

  • Choose any element in nums1 and append a copy of it to the end of nums1.

Return the minimum number of operations required to make nums1 identical to nums2.

Constraints:

  • 1≤1 \leq n ==== nums1.length ≤105\leq 10^5

  • nums2.length ==== n +1+ 1

  • 1≤1 \leq nums1[i], nums2[i] ≤105\leq 10^5