This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package class008;
public class Code01_JumpGameII {
/*
* 评测代码可以直接去leetcode搜索:Jump Game II
*
*/
public static int jump(int[] arr) {
if (arr == null || arr.length == 0) {
return 0;
}
int jump = 0;
int cur = 0;
int next = 0;
for (int i = 0; i < arr.length; i++) {
if (cur < i) {
jump++;
cur = next;
next = Math.max(next, i + arr[i]);
return jump;