Problem 1685 · Medium

Sum of Absolute Differences in a Sorted Array

For each index in a sorted array, compute the total of absolute differences to every other value. The visual splits the array into left and right parts and tracks the running prefix sums.

Open the interactive visualisation