Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 536 Bytes

README.md

File metadata and controls

17 lines (12 loc) · 536 Bytes

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)