Available question text
Given two equal-length arrays, you may replace at most one element in nums1 with any other element from nums1 to minimize the sum of |nums1[i]-nums2[i]|; the challenge is to pick the single best replacement (index and value) that yields the largest reduction in total absolute difference. With n up to 1e5 and values up to 1e5, the typical approach is to pre-sort nums1 and for each index find the closest candidate to nums2[i] (e.g., via binary search) to compute the maximal possible decrease and apply it.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1818. Minimum Absolute Sum Difference
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source