jump_game

  • 2022-12-14
  • 浏览 (441)

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

0  赞