class Solution {
public:
bool isPalindrome(string s) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (s.empty()) {
return true;
}
string temp;
for (int i=0; i<s.size(); i++) {
if (isalnum(s[i])) {
temp.push_back(toupper(s[i]));
}
}
if (temp.size()<=1) {
return true;
}
int beg = 0;
int end = temp.size()-1;
while (beg < end) {
if (temp[beg] == temp[end]) {
beg++;
end--;
} else {
return false;
}
}
return true;
}
};
public:
bool isPalindrome(string s) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (s.empty()) {
return true;
}
string temp;
for (int i=0; i<s.size(); i++) {
if (isalnum(s[i])) {
temp.push_back(toupper(s[i]));
}
}
if (temp.size()<=1) {
return true;
}
int beg = 0;
int end = temp.size()-1;
while (beg < end) {
if (temp[beg] == temp[end]) {
beg++;
end--;
} else {
return false;
}
}
return true;
}
};