You are given two integer arrays arr and brr of equal length, and an integer k.
You can perform the following operations on arr:
Split arr into contiguous subarrays and rearrange them in any order. This operation costs k in total and can be performed at most once.
Increment or decrement any element of arr by
Return the minimum total cost required to make arr equal to brr.
Constraints:
arr.length brr.length
k
arr[i]
brr[i]
You are given two integer arrays arr and brr of equal length, and an integer k.
You can perform the following operations on arr:
Split arr into contiguous subarrays and rearrange them in any order. This operation costs k in total and can be performed at most once.
Increment or decrement any element of arr by
Return the minimum total cost required to make arr equal to brr.
Constraints:
arr.length brr.length
k
arr[i]
brr[i]