Jump Game II

 1 public class Solution {
 2     public int jump(int[] A) {
 3         if(A == null){
 4             return 0;
 5         }
 6         int len = A.length;
 7         if(len == 0 || len == 1){
 8             return 0;
 9         }
10         
11         int cur = 0;
12         int next = 0;
13         int ret = 0;
14         
15         for(int i = 0; i < len; i++){
16             if(i > cur){
17                 cur = next;
18                 ret++;
19             }
20             next = Math.max(next, i + A[i]);
21         }
22         return ret;
23     }
24 }
原文地址:https://www.cnblogs.com/jasonC/p/3431661.html