res = 0
for i in range(1, len(prices)):
diff = prices[i] - prices[i-1]
if diff > 0:
res += diff
return res
cur, end = 0, 0
while end < len(nums) and cur <= end:
end = max(end, cur+nums[cur])
cur += 1
return end >= len(nums)-1
写题的时候逻辑都理不清了,感觉要去放松一下
if len(nums) == 1: return 0
end = 1
start = 0
res = 0
while end < len(nums):
cur = end
new_start = 0
for i in range(start, end):
if nums[i]+i+1 >= cur:
cur = nums[i]+i+1
new_start = i
end = cur
start = new_start+1
res += 1
return res