Plz tell, what is wrong with my code


#1

int Solution::isPalindrome(string A) {
int ans, i=0, j=A.size()-1;
transform(A.begin(), A.end(), A.begin(), ::tolower);
while(i != j){
if(A[i] >= ‘a’ && A[i] < ‘{’){
if(A[j] >= ‘a’ && A[j] < ‘{’){
if(A[i] == A[j]){
ans = 1;
i++;
j–;
}
else{
ans =0;
return ans ;
}
}
else { j–; }
}
else { i++; }
}
return ans;

}


#2

lets say i=5 and j=6.
in your code there is i++; j–;
it will change i to 6 and j to 5.
now i=6 and j=5.
so your loop with condition " while(i != j) " will never end.