class Solution {

public:

int jump(int A[], int n) {

```
if (n == 1) return 0;
int dp[n];
for(int i=0; i<n; i++){
dp[i] = -1;
}
for(int i=n-2; i>=0; i--) {
if( i + A[i] >= n-1 ){
dp[i] = 1;
} else {
int temp = INT_MAX;
for(int j=1; j<=A[i]; j++){
temp = min(temp, dp[i+j]);
}
dp[i] = temp+1;
}
}
return dp[0];
}
```

};