Minimize Squared Differences with a Shared Adjustment Budget
Asked at Verkada · Coding Questions · Difficulty: Hard · Last asked Jul 15, 2026
You are given two integer arrays `A` and `B` of equal length and a non-negative integer `k`. In one operation you add 1 to or subtract 1 from a single element of either array. You may perform at most `k` operations in total, shared across both arrays. After the operations, the cost is the sum of `(A[i] - B[i])^2` over all indices. Return the smallest cost you can reach.
Loading the problem…