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;
}
}
從終點往回跳
Jump Game II
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.