intSolution::jump(vector<int> &A){ if(A.size() == 1) return0; int ma = A[0], now = 0, res = 0; while(now < A.size() - 1and now <= ma) { if(ma >= A.size() - 1) return res + 1; int jump = -1; for(int i = now; i <= ma and i < A.size(); i++) jump = max(jump, i + A[i]); if(ma >= jump and ma != A.size() - 1) return-1; now = ma; ma = jump; res++; } return-1; }