← 返回 sofi 的题目列表Maximum Positive Prefixes
类型:qbank
OA problem: rearrange an array to maximize how many prefix-sum positions are positive, with an explicit complexity requirement.
Requirements
Input is an array of integers.
Rearrange the array to maximize the number of positive elements in the prefix-sum array.
Meet the stated complexity requirement.
A max-heap approach passed the reported OA.
Notes
Track the running prefix sum after choosing the next element.
Clarify whether zeros count as positive; the wording says positive elements, so treat 0 as not positive unless the prompt states otherwise.