from typing import List, Optional
import logging

logger = logging.getLogger(__name__)


class Solution:
    def can_jump(self, nums: List[int]) -> bool:
        """
        You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.

        Return true if you can reach the last index, or false otherwise.
        """
        jump = 0
        for index in range(len(nums)):
            if index > jump:
                return False
            jump = max(jump, index + nums[index])
        return True


def test_base_case():

    assert Solution().can_jump([2, 3, 1, 1, 4]) is True


def test_bad_case():

    assert Solution().can_jump([3, 2, 1, 0, 4]) is False


def test_zero_case():

    assert Solution().can_jump([0]) is True


def test_one_case():

    assert Solution().can_jump([1]) is True


def test_long_solution():
    long_array = [
        2,
        0,
        6,
        9,
        8,
        4,
        5,
        0,
        8,
        9,
        1,
        2,
        9,
        6,
        8,
        8,
        0,
        6,
        3,
        1,
        2,
        2,
        1,
        2,
        6,
        5,
        3,
        1,
        2,
        2,
        6,
        4,
        2,
        4,
        3,
        0,
        0,
        0,
        3,
        8,
        2,
        4,
        0,
        1,
        2,
        0,
        1,
        4,
        6,
        5,
        8,
        0,
        7,
        9,
        3,
        4,
        6,
        6,
        5,
        8,
        9,
        3,
        4,
        3,
        7,
        0,
        4,
        9,
        0,
        9,
        8,
        4,
        3,
        0,
        7,
        7,
        1,
        9,
        1,
        9,
        4,
        9,
        0,
        1,
        9,
        5,
        7,
        7,
        1,
        5,
        8,
        2,
        8,
        2,
        6,
        8,
        2,
        2,
        7,
        5,
        1,
        7,
        9,
        6,
    ]

    assert Solution().can_jump(long_array) is False
