6 line | Short | C++


#1
int Solution::solve(string A) {
    for(int l=0,r=A.size()-1,fl=0;l<=r;)
        if(A[l]==A[r])++l,--r;
        else if(fl)return 0;
        else if(A[r-1]==A[l])--r,fl=1;
        else ++l,fl=1;
    return 1;
}