Jump Game II LeetCode solution in Java

1
class Solution {
2

3
public int jump(int[] nums) {
4

5
int result = 0;
6

7
int L = 0;
8
int R = 0;
9

10
while (R < nums.length - 1) {
11

12
int localMaxRight = 0;
13

14
for (int i = L; i <= R; i++) {
15

16
localMaxRight = Math.max(i + nums[i], localMaxRight);
17
}
18

19
L = R + 1;
20
R = localMaxRight;
21
result++;
22
}
23

24
return result;
25
}
26
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0