0125. Valid Palindrome
class Solution {
public:
bool isPalindrome(string s) {
// two point left and right
// if meet not alpha or number, skip
// compare s[left] and s[right]
// if equal, continue
// if not equal return false
// if left == right, return true
int left = 0, right = s.size() - 1;
for(; left < right; left++, right--) {
while(left < right && !isalnum(s[left])) {
left++;
}
while(left < right && !isalnum(s[right])) {
right--;
}
if(tolower(s[left]) != tolower(s[right])) {
return false;
}
}
return true;
}
};