f[i + j] = min(f[i+j],f[i] + 1)
i:起跳位置
j:跳的步数 (0<=j<=nums[i])
class Solution:
def jump(self, nums: List[int]) -> int:
n = len(nums)
f = [inf for i in range(20 ** 4 + 10)]
f[0] = 0
for i in range(n):
for j in range(nums[i] + 1):
f[i + j] = min(f[i + j],f[i] + 1)
return f[n - 1]