class Solution {
public:
bool check(char &x){
if(x >= 'A' && x <= 'Z') x = x - 'A' + 'a';
if(x >= 'a' && x <= 'z') return true;
if(x >= '0' && x <= '9') return true;
return false;
}
bool isPalindrome(string s) {
int i = 0,j = s.length()-1;
while(i < j){
while(i < j ){
if(check(s[i]))break;
i++;
}
while(j > i){
if(check(s[j]))break;
j--;
}
if(j > i)
if(s[i] != s[j]) return false;
else i++,j--;
}
return true;
}
};
You are here!
Your runtime beats 100.00% of cppsubmissions.