125. Valid Palindrome

image.png
class Solution {
public:
    bool isPalindrome(string s) {
        vector words;
        if(s.empty()) return true;
        for(int i = 0; i < s.length(); i++){
            if(isalnum(s[i])){
                words.push_back(tolower(s[i]));
            }
        }
        if(words.empty()) return true;
        auto l = words.begin();
        auto r = words.end();
        r--;
        cout<<*r<

你可能感兴趣的:(125. Valid Palindrome)