class Solution {
public:
//f[i]表示跳到i所需的最小步数
int jump(vector<int>& nums) {
vector<int> f(10010,0x3f3f3f3f);
int n=nums.size();
f[0]=0;
for(int i=0;i<n;i++)
for(int j=0;j<i;j++)//枚举能从哪个位置跳过来
if(j+nums[j]>=i)
f[i]=min(f[i],f[j]+1);
return f[n-1];
}
};
标签:nums,int,II,vector,跳跃,LeetCode45
From: https://www.cnblogs.com/tangxibomb/p/17251457.html