Problem 2779 · Medium

Maximum Beauty of an Array After Applying Operation

Sort the values and slide a window whose spread is at most 2k, since each value can move by k in either direction.

Open the interactive visualisation