第三题瞎蒙的偏暴力的线性dp,居然A了100😂 class Solution: def solute(self,nums): if len(nums) < 2: return 0 dp = [i for i in range(1,len(nums)+1)] 遍历数组 for i,n in enumerate(nums): 计算从该站跳到下一站,下一站的最小次数 next_hop = dp[i]+1 for j in range(i,i+n+1): if j >= len(nums): break dp[j] = min(dp[j],next_hop) return dp[-1]-1 n = int(input()) nums = list(map(int,input().strip().split())) s = Solution() nums = [1,1,1,1,1,1] nums = [2,3,1,1] print(s.solute(nums))