标签:img span div def return pac leetcode code class
我真的是超开心了,又做对了!!!!!!而且没走啥弯路!!!!!!!
class Solution(object): def jump(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums)<2: return 0 pact=0 i=0 while i<len(nums): if nums[i]>=len(nums)-i-1: pact+=1 return pact else: pact+=1 m=0 k=[0] for j in range(i,i+nums[i]+1): if nums[j]>=len(nums)-j-1: pact+=1 return pact else: if j+nums[j]>m: m=j+nums[j] k[0]=j i=k[0]
执行用时为 68 ms 的范例 class Solution(object): def jump(self, nums): """ :type nums: List[int] :rtype: int """ cur = pre = step = 0 for i in range(len(nums)-1): cur = max(cur,nums[i]+i) if i == pre: step += 1 pre = cur return step
——2019.10.14
标签:img span div def return pac leetcode code class
原文地址:https://www.cnblogs.com/taoyuxin/p/11671059.html