# Не решил ...


from typing import List


class Solution:
    def canJump(self, nums: List[int]) -> bool:
        def calculate_jump_for_elem(elem, elem_index):
            if elem == len(nums):
                return True
            for jump_distance in range(elem, -1, -1):
                if (elem_index + jump_distance) == len(nums) - 1:
                    return True
                if jump_distance == 0:
                    continue
                jump_index = elem_index + jump_distance
                if jump_index > len(nums) - 1:
                    continue
                next_elem = nums[jump_index]
                return calculate_jump_for_elem(next_elem, jump_index)

        res = calculate_jump_for_elem(nums[0], 0)
        return res if res else False


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