Python | Leetcode Python题解之第517题超级洗衣机

题目:

题解:

python 复制代码
class Solution:
    def findMinMoves(self, machines: List[int]) -> int:
        tot = sum(machines)
        n = len(machines)
        if tot % n:
            return -1
        avg = tot // n
        ans, s = 0, 0
        for num in machines:
            num -= avg
            s += num
            ans = max(ans, abs(s), num)
        return ans
相关推荐
程序员的世界你不懂26 分钟前
【Flask】测试平台开发,工具模块开发 第二十二篇
android·python·flask
薰衣草23331 小时前
滑动窗口(2)——不定长
python·算法·leetcode
User_芊芊君子2 小时前
【JavaSE】复习总结
java·开发语言·python
计算机毕业设计木哥2 小时前
计算机毕业设计 基于Python+Django的医疗数据分析系统
开发语言·hadoop·后端·python·spark·django·课程设计
Python×CATIA工业智造2 小时前
Python索引-值对迭代完全指南:从基础到高性能系统设计
python·pycharm
Luchang-Li3 小时前
sglang pytorch NCCL hang分析
pytorch·python·nccl
一个天蝎座 白勺 程序猿8 小时前
Python爬虫(47)Python异步爬虫与K8S弹性伸缩:构建百万级并发数据采集引擎
爬虫·python·kubernetes
XiaoMu_0019 小时前
基于Django+Vue3+YOLO的智能气象检测系统
python·yolo·django
honder试试10 小时前
焊接自动化测试平台图像处理分析-模型训练推理
开发语言·python
心本无晴.10 小时前
Python进程,线程
python·进程