Problem 1589 · Medium

Maximum Sum Obtained of Any Permutation

Count how many requests cover each position with a difference array, then pair the largest values with the largest counts.

Open the interactive visualisation