Search
⌘K

Leetcode 2587. Rearrange Array to Maximize Prefix Score

Reorder the elements of an array to maximize the number of positive prefix sums — i.e., choose a sequence that keeps the running cumulative sum positive for as many prefixes as possible. This is an ordering/greedy optimization on prefix sums (n up to 1e5, values up to ±1e6).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.