Jump Game - Leetcode Below is my solution for the LeetCode Jump Game

Given an array of non-negative integers, you are initially positioned
at the first index of the array.
Each element in the array represents your maximum jump length at that
position.
Determine if you are able to reach the last index.

Example 1:

Input: [2,3,1,1,4]
Output: true

This is my solution. It is correct but timed out the LeetCode code-checker for an array of 25000 elements.
Please can someone help me improve this code.
It seems to have a time complexity of O(N^2) and a space complexity of O(N). I cannot work out a method faster than O(N^2).
def function(nums):
    if len(nums) == 1:
        return True
    output = [0] * len(nums)
    last_index = len(nums) - 1
    output[0] = 1

    for index, number in enumerate(nums):
        if output[index] == 0:
            continue
        if output[index] == 1:
            stop_at = min(last_index, index + number)
            for i in range(index, stop_at + 1):
                output[i] = 1
        if output[last_index] == 1:
            return True
    return False


if __name__ == &quot;__main__&quot;:
    nums = [3,2,1,0,4]
    output = function(nums)
    print(output)
O(n) Solution

You don't need to keep track of all the places you can reach.  You only need to know what is the highest index you can reach, because you can reach any lower index by choosing a shorter jump.  Scan the list from 0 to the end keeping track of the maximum reachable index.  If you ever reach an index greater than the maximum reachable index, you've hit a block and can't reach the end.

For example, for a jump list = [3,2,1,0,4].  Starting at index 0, we can reach any index up to 0 + 3 = 3.  From index 1 we can reach 1 + 2 = 3.  From 2, we can reach 2+1 = 3.  From index 3, we can reach 3 + 0 = 3.  So far the maximum reachable index is 3.  So when we reach index 4, 4 > 3 so index 4 is unreachable and we can't get to the end.

def canjump(nums):
    maximum_reachable_index = 0

    for index, max_jump in enumerate(nums):
        #print(f"{index}", end=' ')
        if index &gt; maximum_reachable_index:
            #print(f"&gt; {maximum_reachable_index} and is unreachable.")
            return False

        #print(f"+ {max_jump} =&gt; {index + max_jump} : {maximum_reachable_index} ")
        maximum_reachable_index = max(index + max_jump, maximum_reachable_index)

    return True


Uncomment the print statements to see how it works.