技术栈

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

Mopes__2024-10-31 3:06

题目:

题解:

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
上一篇:rhcsa、ce复习(每日编辑,复习完为止)
下一篇:LeetCode 202 - 快乐数
相关推荐
2501_94542354
1 小时前
用Matplotlib绘制专业图表:从基础到高级
jvm·数据库·python
2301_79380469
1 小时前
使用Python处理计算机图形学(PIL/Pillow)
jvm·数据库·python
吴佳浩
7 小时前
GPU 编号进阶:CUDA\_VISIBLE\_DEVICES、多进程与容器化陷阱
人工智能·pytorch·python
全栈凯哥
8 小时前
18.Python中的导入类完全指南
python
sunwenjian886
8 小时前
Java进阶——IO 流
java·开发语言·python
参.商.
8 小时前
【Day41】143. 重排链表
leetcode·golang
guts350
9 小时前
图像篡改数据集下载:COVERAGE、CASIA
python·数据集
森林猿
9 小时前
java-modbus-读取-modbus4j
java·网络·python
2401_87969387
9 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
chushiyunen
9 小时前
python chatTts实现tts文本转语音、音频
python
热门推荐
01GitHub 镜像站点02围棋-html版本03Qwen3.5 开源全解析:从 0.8B 到 397B,代际升级 + 全场景选型指南04小黑课堂计算机二级WPSoffice题库软件下载安装教程(2026年3月最新版)05班级宠物园部署指南06OpenClaw 使用和管理 MCP 完全指南07OpenClaw Control UI安全上下文访问配置08UV安装并设置国内源09“wsl --install -d Ubuntu-22.04”下载慢,中国地区离线安装 Ubuntu 22.04 WSL方法(亲测2025年5月6日)102026年03月18日热门Model/github项目