class Solution {
public:
bool isPalindrome(string s) {
int st = 0, ed = s.length();
if (ed == 0) {
return true;
}
while (st < ed) {
if (!isalpha(s[st]) && !isdigit(s[st])) {
++st;
} else if(isalpha(s[ed]) || isdigit(s[ed])) {
if (toupper(s[st]) != toupper(s[ed])) {
break;
}
++st;
--ed;
} else {
--ed;
}
}
return st >= ed;
}
};