Posted on

Description

Submission

class Solution {
public:
    bool isPalindrome(string s) {
        string t = "";
        for(int i = 0; i < s.size(); ++i) {
            if((s[i] <= 'z' && s[i] >= 'a') || (s[i] <= 'Z' && s[i] >= 'A')) {
                t.push_back(tolower(s[i]));
            } else if(s[i] <= '9' && s[i] >= '0') {
                t.push_back(s[i]);
            }
        }
        for(int i = 0, j = t.size() - 1; i <= j; --j, ++i) {
            if(t[i] != t[j]) return false;
        }
        return true;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *