l = [2, 3, 1, 1, 4]
n = len(l)
maxpro, end, step = 0, 0, 0
for i in range(n-1):
maxpro = max(maxpro, i + l[i])
if end == i:
end = maxpro
step += 1
print(step)
跳跃游戏||
最新推荐文章于 2024-08-05 17:27:03 发布
l = [2, 3, 1, 1, 4]
n = len(l)
maxpro, end, step = 0, 0, 0
for i in range(n-1):
maxpro = max(maxpro, i + l[i])
if end == i:
end = maxpro
step += 1
print(step)