You are given two positive integer arrays nums and target of the same length n.
In one operation, you can choose two distinct indices i and j and perform the following actions:
Increment nums[i] by
Decrement nums[j] by
Two arrays are considered similar if both arrays contain the exact same elements with the same frequencies.
Return the minimum number of operations required to make nums similar to target.
Constraints:
n nums.length target.length
n
nums[i], target[i]
It is possible to make nums similar to target.
You are given two positive integer arrays nums and target of the same length n.
In one operation, you can choose two distinct indices i and j and perform the following actions:
Increment nums[i] by
Decrement nums[j] by
Two arrays are considered similar if both arrays contain the exact same elements with the same frequencies.
Return the minimum number of operations required to make nums similar to target.
Constraints:
n nums.length target.length
n
nums[i], target[i]
It is possible to make nums similar to target.