You're given two positive integer arrays nums1 and nums2, both of length n.
The absolute sum difference of these arrays is defined as the sum of |nums1[i] - nums2[i]| for each index 0 ≤ i < n.
Here's the twist: You can replace at most one element of nums1 with any other element that already exists in nums1 to minimize the absolute sum difference.
Goal: Return the minimum possible absolute sum difference after performing this optional replacement. Since the answer may be large, return it modulo 109 + 7.
Example: If nums1 = [1,7,5] and nums2 = [2,3,5], the initial differences are [1,4,0] with sum = 5. By replacing nums1[1] = 7 with nums1[0] = 1, we get differences [1,2,0] with sum = 3.
Input & Output
Constraints
- n == nums1.length
- n == nums2.length
- 1 ≤ n ≤ 105
- 1 ≤ nums1[i], nums2[i] ≤ 105
- You can replace at most one element