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
相关推荐
applebomb6 分钟前
没合适的组合wheel包,就自行编译flash_attn吧
python·ubuntu·attention·flash
Chasing__Dreams36 分钟前
python--杂识--18.1--pandas数据插入sqlite并进行查询
python·sqlite·pandas
黑听人44 分钟前
【力扣 困难 C】115. 不同的子序列
c语言·leetcode
彭泽布衣1 小时前
python2.7/lib-dynload/_ssl.so: undefined symbol: sk_pop_free
python·sk_pop_free
喜欢吃豆2 小时前
从零构建MCP服务器:FastMCP实战指南
运维·服务器·人工智能·python·大模型·mcp
一个处女座的测试2 小时前
Python语言+pytest框架+allure报告+log日志+yaml文件+mysql断言实现接口自动化框架
python·mysql·pytest
nananaij3 小时前
【Python基础入门 re模块实现正则表达式操作】
开发语言·python·正则表达式
蛋仔聊测试3 小时前
Playwright 网络流量监控与修改指南
python
前端拿破轮3 小时前
🤡🤡🤡面试官:就你这还每天刷leetcode?连四数相加和四数之和都分不清!
算法·leetcode·面试
nightunderblackcat3 小时前
进阶向:Python音频录制与分析系统详解,从原理到实践
开发语言·python·音视频