values. You may reorder its numbers in any way (keeping the original order is allowed too). Then walk the array left to right and, after each number, write down the running total: the sum of everything from the start up to and including that number.
Return the largest number of strictly positive running totals you can get by choosing the order.values=[-4, 3, 0, 2, -2] → 4
The order [3, 2, 0, -2, -4] gives running totals 3, 5, 5, 3, -1, four of them positive. Five is impossible: the whole array sums to a negative number.
values=[0, -1] → 0
There are no positive numbers, so no running total can be above zero.
values=[5, -5, 1] → 3
values=[-4, 3, 0, 2, -2]
4
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.