Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Equal to Target

Minimum Operations to Make Array Equal to Target gives two equal-length integer arrays; find the fewest operations to match them by incrementing or decrementing any contiguous subarray by one.

Statement

You are given two integer arrays nums and target of equal length.

In a single operation, you can choose any contiguous subarray of nums and increment or decrement all values within that subarray by 11.

Return the minimum number of operations needed to transform nums into target.

Constraints:

  • 1≤1 \leq nums.length == target.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], target[i] ≤108\leq 10^8

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Equal to Target

Minimum Operations to Make Array Equal to Target gives two equal-length integer arrays; find the fewest operations to match them by incrementing or decrementing any contiguous subarray by one.

Statement

You are given two integer arrays nums and target of equal length.

In a single operation, you can choose any contiguous subarray of nums and increment or decrement all values within that subarray by 11.

Return the minimum number of operations needed to transform nums into target.

Constraints:

  • 1≤1 \leq nums.length == target.length ≤105\leq 10^5

  • 1≤1 \leq nums[i], target[i] ≤108\leq 10^8