Skip to content

Commit 74f3a0a

Browse files
45. Jump Game II (java)
1 parent a2172e7 commit 74f3a0a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int jump(int[] nums) {
3+
int cnt = 0,last = 0, next = 1;
4+
for (;next < nums.length;cnt++){
5+
int i = last;
6+
last = next;
7+
for (; i < last; ++i) if (i + nums[i] >= next) next = i + nums[i] + 1;
8+
}
9+
return cnt;
10+
}
11+
}

0 commit comments

Comments
 (0)