```
class Solution {
public:
int jump(vector<int>& nums) {
int n = nums.size();
int maxm = nums[0];
int cnt = 0;
for(int i=0;i<n-1;){
cnt++;
int p = maxm;
for(int j=i;j<=p and j<n;j++){
maxm = max(maxm,j+nums[j]);
}
i = p;
}
return cnt;
}
};
```