其他分享
首页 > 其他分享> > 55. 跳跃游戏

55. 跳跃游戏

作者:互联网

 思路参考:力扣icon-default.png?t=L892https://leetcode-cn.com/problems/jump-game/solution/pythonji-bai-97kan-bu-dong-ni-chui-wo-by-mo-lan-4/

代码:

class Solution:
    def canJump(self, nums: List[int]) -> bool:
        max_dis = 0

        for inx, value in enumerate(nums):
            if max_dis >= inx and inx + value >= max_dis:
                max_dis = max(max_dis, inx + value)

        return max_dis >= inx

 

 

标签:inx,游戏,nums,55,max,value,跳跃,cn,dis
来源: https://blog.csdn.net/wdh315172/article/details/120623574