您的位置:首页 > 其它

Jump Game II

2013-04-23 17:10 197 查看
public class Solution {
public int jump(int[] A) {
// Start typing your Java solution below
// DO NOT write main() function
if(A==null)return 0;
int len = A.length;
int now = len - 1;
int count = 0;
while(now != 0){
for(int i = 0; i < now; i++){
if(A[i]>=now-i){
count++;
now = i;
break;
}
}
}
return count;
}
}
从终点往回跳
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  贪心