Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 332 Bytes

125. Valid Palindrome.md

File metadata and controls

14 lines (13 loc) · 332 Bytes
class Solution {
public:
    bool isPalindrome(string s) {
        for (int i = 0, j = s.size() - 1; i < j; ++i, --j) {
            while (!isalnum(s[i]) && i < j) ++i;
            while (!isalnum(s[j]) && i < j) --j;
            if (toupper(s[i]) != toupper(s[j])) return false;
        }
        return true;
    }
};