2674. Make the Prefix Sum Non-negative

Medium
Array
Greedy
Heap (Priority Queue)

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.

Statistics

Acceptance
51.9%
Submissions
16,018
Accepted
8,306