Skip to content

Latest commit

 

History

History

45-JumpGameII

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Jump Game II

Problem can be found in here!

Solution: Greedy

def jump(nums: List[int]) -> int:
    start = end = step = 0
    while end < len(nums) - 1:
        step += 1
        start, end = end+1, max(i+nums[i] for i in range(start, end+1))

    return step

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