<reponame>kokuraxc/play-ground
# https://leetcode.com/problems/jump-game/


class Solution:
    def canJump(self, nums: list[int]) -> bool:
        last = 0
        for index in range(len(nums)):
            if index > last:
                return False
            last = max(last, index + nums[index])
            if last >= len(nums) - 1:
                return True
        return True


nums = [2, 3, 1, 1, 4]
print(Solution().canJump(nums))

nums = [3, 2, 1, 0, 4]
print(Solution().canJump(nums))