C++ solution with every corner case being taken care of


#1

int isPalindrome(string s, int i, int j){
s = s.substr(i, j-i+1);
string rev = s;
reverse(rev.begin(), rev.end());
if(rev==s)
return 1;
return 0;
}

int Solution::solve(string A) {

int n = A.length();
int i = 0; 
int j = n-1;

while(i<=j){
    if(A[i]!=A[j]){
        if(isPalindrome(A, i+1, j) || isPalindrome(A, i, j-1))
            return 1;
        else
            return 0;
    }
    i++;
    j--;
}

return 1;

}