I 'm not sure why this code is wrong, Can some one help me please.


  • 0
    S

    def jump(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    jumps = [sys.maxint] * len(nums)

        jumps[0] = min(0, nums[0])
        
        for index, count in enumerate(nums[1:]):
            for prev in xrange(index):
                if nums[prev] + prev >= index:
                    jumps[index] = min(jumps[index], jumps[prev] + 1)
        
        return jumps[-1]

Log in to reply
 

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