问题描述
You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.
For each move, you could choose any m (1 ≤ m ≤ n) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at the same time .
Given an integer array representing the number of dresses in each washing machine from left to right on the line, you should find the minimum number of moves to make all the washing machines have the same number of dresses. If it is not possible to do it, return -1.
Example1
Example2
517. Super Washing Machines(超级洗衣机)
最新推荐文章于 2022-07-25 23:15:19 发布
该问题要求找到最小的移动次数使所有洗衣机衣服数量相等。条件是衣服总数是洗衣机数量的倍数,目标数量是总数除以洗衣机数。通过累加计算每台洗衣机的移动步数,记录最大值作为最少步数。如果无法达到平衡,则返回-1。
摘要由CSDN通过智能技术生成