class Solution {
public:
bool canCross(vector<int>& stones) {
vector[HTML_REMOVED]>f=vector[HTML_REMOVED]>(stones.size(),vector[HTML_REMOVED](stones.size(),false));
f[0][0]=true;
for(int i=1;i<stones.size();i){
for(int j=0;j<i;j){
int k=stones[i]-stones[j];
if(k<=j+1){
f[i][k]=f[j][k-1]||f[j][k]||f[j][k+1];
if(i==stones.size()-1&&f[i][k])return true;
}
}
}
return false;
}
};