#3424
Minimum Cost to Make Arrays Identical
expert · 1050 · lc medium +32 · 37.7% accepted · 86 likes · top 16%
Description
You are given two integer arrays arr and brr of length n, and an integer k. You may apply any number of operations to arr:
- Split arr into any number of contiguous subarrays and rearrange them in any order; this costs k.
- Add or subtract any positive integer x to any element of arr; this costs x.
Return the minimum total cost to make arr equal to brr.
Code
1
2
3