技术栈

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 - 快乐数
相关推荐
黄忠
13 分钟前
大模型之LangGraph技术体系
python·llm
hboot
13 小时前
AI工程师第二课 - 数据处理
人工智能·python·数据分析
用户835629078051
18 小时前
使用 Python 自动化 PowerPoint 形状布局与格式设置
后端·python
用户835629078051
19 小时前
用 Python 自动化 PowerPoint 演讲者备注添加
后端·python
黄忠
1 天前
01-系统架构设计-LangGraph状态机与多源异构RAG
python
zzzzzz310
1 天前
假如我是掘金管理员,我先给评论区装个'代码审查'系统
python·程序员·机器人
砍材农夫
1 天前
python环境|conda安装和使用(2)
后端·python
程序员龙叔
2 天前
编写高质量 Skill 系列 -- 如何设计需求分析与用例生成的 SKILL
自动化测试·软件测试·python·软件测试工程师·接口测试·性能测试·skill·ai测试
用户835629078051
2 天前
使用 Python 操作 Word 内容控件
后端·python
热门推荐
012026年6月AI行业全景:从百模大战到Agent元年,这30天发生了什么?022026 年 AI 编程工具终极横评:Cursor vs Claude Code vs Copilot vs Windsurf032026年6月AI大模型全景报告:GPT-5.6、Claude Opus 4.8、Gemini 3.5,中美AI三足鼎立谁主沉浮?04【AI】2026 年具身智能模型和世界模型总结052026 AI 编程工具终极实战指南:Cursor vs Claude Code vs Copilot,开发者该怎么选?06GitHub 镜像站点07AI科技热点日报 | 2026年6月1日08上线仅72小时被强制下架:Claude Fable 5 的短命09Codex 下载安装指南:Windows 和 macOS 官方版下载10AI一周事件 · 2026-06-03 至 2026-06-09