1 class Solution { 2 public: 3 int jump(int A[], int n) { 4 5 if (n <= 1) return 0; 6 7 int maxReachedLastTime = 0; 8 int maxReachedNow = 0; 9 int minSteps = 0; 10 11 for (int index = 0; index<n; index++){ 12 13 if (index > maxReachedLastTime){ 14 15 maxReachedLastTime = maxReachedNow; 16 minSteps++; 17 } 18 19 if (index+A[index]>maxReachedNow) maxReachedNow = index+A[index]; 20 } 21 22 return minSteps; 23 } 24 };