Practice Minimum Sum of Squared Difference
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2333
LeetCode ProblemMinimum Sum of Squared Difference
Problem Statement
For equal-length arrays nums1 and nums2, minimize the sum of (nums1[i] - nums2[i])^2 over all indices. One operation changes an entry by +1 or -1. Use at most k1 operations on nums1 and at most k2 on nums2; entries may become negative. Return the minimum sum.
Source: Minimum Sum of Squared Difference on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums1 = [1,2,3,4], nums2 = [2,10,20,19], k1 = 0, k2 = 0
Output
579
# Example 2
Input
nums1 = [1,4,10,12], nums2 = [5,8,6,9], k1 = 1, k2 = 1
Output
43
Constraints
n == nums1.length == nums2.length
1 <= n <= 10^5
0 <= nums1[i], nums2[i] <= 10^5
0 <= k1, k2 <= 10^9
Related LeetCode Problems
Practice more problems similar to Minimum Sum of Squared Difference.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.