Problem 2587 · Medium

Rearrange Array to Maximize Prefix Score

Sort the numbers from largest to smallest so the running sum stays positive for as many prefixes as possible.

Open the interactive visualisation