Record the minimal and maximal possible next step at each stone, and move forward.

```
public class Solution {
public boolean canCross(int[] stones) {
if (stones.length <= 1){
return true;
}
int n = stones.length;
int[] minNextStep = new int[n];
int[] maxNextStep = new int[n];
Arrays.fill(minNextStep, Integer.MAX_VALUE);
minNextStep[0] = 1;
maxNextStep[0] = 1;
for (int i = 0; i < n; i++){
if (minNextStep[i] > maxNextStep[i]){
return false;
}
int j = i + 1;
for (int k = Math.max(1, minNextStep[i]); k <= maxNextStep[i]; k++){
if (j >= n){
break;
}
if (stones[i] + k < stones[j]){
continue;
} else if (stones[i] + k == stones[j]){
minNextStep[j] = Math.min(minNextStep[j], k - 1);
maxNextStep[j] = Math.max(maxNextStep[j], k + 1);
j++;
} else{
j++;
}
}
}
return true;
}
}
```