Minimize Sum of Prefix Ranges by Reordering
Asked at Amazon · Coding Questions · Difficulty: Hard
Given `productSize`, you may reorder the items. For each prefix (first `i` items) define `variation[i] = max(first i) - min(first i)`. Reorder to minimize the total sum of all `variation[i]`, and return that minimum sum.
Loading the problem…