Leetcode/leetcode45

45. Jump Game II

参考
题目

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;

}
}

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×