Just write down my thought and the code maybe pretty same with others

  • 0

    We go through the array from left to right or reverse.
    [1]count the all number of dress we need to operate with the other side up to now as A (that means the dress we have to give out or we lack).
    [2]in every step, the Math.abs(A) maybe final answer.
    [3]for every machine, if it have more dress than avg, it must will take (his dress number)-(avg) times operate to make it be in avg. So it also maybe the final answer.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.