3424. Minimum Cost to Make Arrays Identical
You are given two integer arrays
arr
andbrr
of lengthn
, and an integerk
. You can perform the following operations onarr
any number of times:
- Split
arr
into any number of contiguous subarrays and rearrange these subarrays in any order. This operation has a fixed cost ofk
.- Choose any element in
arr
and add or subtract a positive integerx
to it. The cost of this operation isx
.Return the minimum total cost to make
arr
equal tobrr
.A subarray is a contiguous non-empty sequence of elements within an array.
1 | class Solution { |