8 lines python solution


  • 0
    N

    '''
    class Solution(object):
    def jump(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    l, lower_bound, upper_bound, c = len(nums), 0, 0, 0
    while True:
    if lower_bound >= l-1 or upper_bound >= l - 1:
    return c
    temp = upper_bound
    upper_bound = max([_ + nums[_] for _ in range(lower_bound, upper_bound+1)])
    lower_bound = temp + 1
    c += 1
    '''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.