Who can tell me why I meet with this problem?

I know that I didn't deal with the 0, but I don't think it's the problem.

Would you please help me?

Thanks.

Last executed input: [25000,24999,24998,24997,24996,24995,24994,24993,24992,24991,24990,24989,24988,24987,24986,24985,24984......

```
class Solution {
public:
int jump(int A[], int n) {
if( n == 0 || n == 1 )
return 0;
if( n ==2 || A[0] >= n-1 )
return 1;
int* dp = new int[n];
memset( dp, 0, n);
for( int i = 0; i < n; ++i ) {
int maxj = A[i];
if( maxj + i + 1 >= n ) {
return dp[i] + 1 ;
}
for( int j = i + 1; j < maxj + i + 1; ++j ) {
if( dp[j] == 0 ) {
dp[j] = dp[i] + 1;
}
}
}
return dp[n-1];
}
};
```