Skip to content

Latest commit

 

History

History

55-JumpGame

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Jump Game

Problem can be found in here!

Solution: Greedy

def canJump(nums: List[int]) -> bool:
    last_position = len(nums)-1
    for index in range(len(nums)-1, -1, -1):
        if index + nums[index] >= last_position:
            last_position = index

    return last_position == 0

Time Complexity: O(n), Space Complexity: O(n)