点击打开链接
//贪心
class Solution {
public:
int Jump(vector<int>& nums) {
int ret=0, curMax=0, curRch =0;
for(int i=0; i<nums.size(); i++){
if(curRch < i){
ret +=1;
curRch = curMax;
}
curMax = max(curMax, nums[i]+i);
}
return ret;
}
};