1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| class Solution { public int jump(int[] nums) { int dept=0; int cursor = 0,i=0; while(cursor<nums.length-1) { dept++; int limit = cursor; for(;i<=limit;i++) { cursor = Math.max(cursor, i+nums[i]); } } return dept; } }
|