```
int jump(vector<int>& nums) {
int len = nums.size();
vector<int> minJumps(len,INT_MAX);
minJumps[0] = 0;
for (int i = 0;i < len;++i) {
if (nums[i] == INT_MAX) return -1;
for (int j = min(len-1,i+nums[i]);j > i;--j)
if (minJumps[j] <= minJumps[i]+1)
break;
else
minJumps[j] = minJumps[i]+1;
}
return minJumps.back();
}
```