Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 558 Bytes

README.md

File metadata and controls

17 lines (12 loc) · 558 Bytes

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)