Python | Leetcode Python题解之第45题跳跃游戏II

题目:

题解:

python 复制代码
class Solution:
    def jump(self, nums: List[int]) -> int:
        n = len(nums)
        maxPos, end, step = 0, 0, 0
        for i in range(n - 1):
            if maxPos >= i:
                maxPos = max(maxPos, i + nums[i])
                if i == end:
                    end = maxPos
                    step += 1
        return step
相关推荐
Blossom.1181 天前
强化学习推荐系统实战:从DQN到PPO的演进与落地
人工智能·python·深度学习·算法·机器学习·chatgpt·自动化
Alice10291 天前
如何在windows本地打包python镜像
开发语言·windows·python
南屿欣风1 天前
Sentinel @SentinelResource:用 blockHandler 实现优雅的接口降级
开发语言·python
嫂子的姐夫1 天前
012-AES加解密:某勾网(参数data和响应密文)
javascript·爬虫·python·逆向·加密算法
Jeremy爱编码1 天前
电话号码的字母组合
java·算法·leetcode
爱吃提升1 天前
Python 使用 MySQL 数据库进行事务处理步骤
数据库·python·mysql
avi91111 天前
python大模型训练(一)如何查看工具package版本
python·aigc
YuTaoShao1 天前
【LeetCode 每日一题】1339. 分裂二叉树的最大乘积
算法·leetcode·职场和发展
pulinzt1 天前
【python第三节】循环+函数初步
开发语言·python
leoufung1 天前
LeetCode 172. Factorial Trailing Zeroes 题解
算法·leetcode·职场和发展