jump_game

2022-12-14 浏览 (1048)

jump_game.py 源码

from typing import List


# 跳跃游戏

class Solution:

    def canJump(self, nums: List[int]) -> bool:
        k = 0
        for i in range(len(nums)):
            if i > k:
                return False
            k = max(k, i + nums[i])
        return True

你可能感兴趣的文章

algo-learn

contains_duplicate

container_with_most_water

  • 所属分类: 后端技术
  • 本文标签: 技术
  • 版权声明: 本文链接 https://seaxiang.com/blog/a42de0b69273462e9654f75afee28c61