
Calculate the average number of dresses per machine.

Don't worry about each machine should borrow dresses or give out dresses, transform all to giveout => machines[i] = machines[i]  average, yes you can give out a negative amount to dresses.

Max(machines[i]) should be the answer, yes at least you need to do machines[i] operations to give out machines[i] dresses.

Wait, what if there is an accumulated number of giveouts that's greater than Max(machines[i])? Then use that accumulated number as the answer since those two giveouts can happen simultaneously. Example: [1, 1, 1, 0, 5, 0, 2], 1 + 1 + 1 > 2, so answer is 1 + 1 + 1 = 3.
Just a simple explanation


@wz366 your solution will not work for this case
[0,0,11,5]
in this case, the average dresses per machine is 4. and the array of machines[i]average is
[4,4,7,1]
in this case maximum give out is 7, there are no accumulated give outs that are more than 7, so according to your algorithm, the solution is 7. But the actual answer is 8.
Can you Please explain your algorithm or correct me if i have understood it wrong.
Thanks

@RepentThySins If we go from right to left 1 + 7 accumulate to 8. If we go from left to right, Math.abs(4 + 4) accumulate to 8. Negative give outs are also give outs.
