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
相关推荐
AI小云13 分钟前
【数据操作与可视化】Pandas数据处理-Series数据结构
开发语言·数据结构·python·numpy·pandas
Python大数据分析@25 分钟前
如何理解Python中的yield用法?
python
Miraitowa_cheems1 小时前
LeetCode算法日记 - Day 108: 01背包
数据结构·算法·leetcode·深度优先·动态规划
源码之家1 小时前
基于python新闻数据分析可视化系统 Hadoop 新闻平台 爬虫 情感分析 舆情分析 可视化 Django框架 vue框架 机器学习 大数据毕业设计✅
大数据·爬虫·python·数据分析·毕业设计·情感分析·新闻
IT油腻大叔1 小时前
DeepSeek-多层注意力计算机制理解
python·深度学习·机器学习
小呀小萝卜儿1 小时前
2025-11-17 学习记录--Python-机器学习作业:项目1 - PM2.5预测
python·学习·机器学习
闲人编程1 小时前
CPython与PyPy性能对比:不同解释器的优劣分析
python·算法·编译器·jit·cpython·codecapsule
小武~2 小时前
Leetcode 每日一题C 语言版 -- 88 merge sorted array
c语言·算法·leetcode
kk哥88992 小时前
PyCharm 2025.1 是什么编程语言,如何安装
python·php
海拥2 小时前
基于 IPIDEA 的 SERP 结构化数据抽取与趋势监控的工程化实践
python