s4553711
7/3/2017 - 1:29 PM

125.cpp

class Solution {
public:
    bool isPalindrome(string s) {
        if (s.length() == 0) return true;
        int i = 0, e = s.length() - 1; 
        while(i < e) {
            while (i < e && !isalnum(s[i])) {
                i++;
            }
            while (i < e && !isalnum(s[e])) {
                e--;
            }
            if (i < e && tolower(s[i]) != tolower(s[e])) {
                return false;
            } else {
                i++;
                e--;
            }
        }
        return true;
    }
};