class Solution {
public:
bool isPalindrome(string s) {
int head = 0;
int tail = s.size() - 1;
if(tail<0) return true;
while(head<=tail){
if(!((s[head]>='0' && s[head] <='9')|| ( s[head]>='A' && s[head] <= 'Z') || (s[head]>='a' && s[head] <= 'z'))){
head++;
continue;
}
if(!((s[tail]>='0' && s[tail] <='9')||(s[tail]>='A' && s[tail] <= 'Z' )||( s[tail]>='a' && s[tail] <= 'z'))){
tail--;
continue;
}
s[head] = (s[head]>='A' && s[head] <= 'Z') ? s[head] - 'A' + 'a' : s[head];
s[tail] = (s[tail]>='A' && s[tail] <= 'Z') ? s[tail] - 'A' + 'a' : s[tail];
if(s[head]!=s[tail]){
return false;
}else{
head++;
tail--;
}
}
return true;
}
};
public:
bool isPalindrome(string s) {
int head = 0;
int tail = s.size() - 1;
if(tail<0) return true;
while(head<=tail){
if(!((s[head]>='0' && s[head] <='9')|| ( s[head]>='A' && s[head] <= 'Z') || (s[head]>='a' && s[head] <= 'z'))){
head++;
continue;
}
if(!((s[tail]>='0' && s[tail] <='9')||(s[tail]>='A' && s[tail] <= 'Z' )||( s[tail]>='a' && s[tail] <= 'z'))){
tail--;
continue;
}
s[head] = (s[head]>='A' && s[head] <= 'Z') ? s[head] - 'A' + 'a' : s[head];
s[tail] = (s[tail]>='A' && s[tail] <= 'Z') ? s[tail] - 'A' + 'a' : s[tail];
if(s[head]!=s[tail]){
return false;
}else{
head++;
tail--;
}
}
return true;
}
};