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