Fetching data...
This may take a moment
Back
2674. Make the Prefix Sum Non-negative
Medium
Array
Greedy
Heap (Priority Queue)
Solve on LeetCode
View Solutions
Description
Hints
Hint 1
There will always be a way to make the prefix sum non-negative. How can we use that?
Hint 2
Loop over the array keeping the prefix sum. Whenever it goes negative, move the smallest number you have seen to the end.
Similar Questions
Furthest Building You Can Reach
Medium
Maximum Transactions Without Negative Balance
Medium
Statistics
Acceptance
51.9%
Submissions
16,018
Accepted
8,306