leetcode 125. Valid Palindrome

class Solution {
public:
    bool isPalindrome(string s) {
        int length = s.length();
        if(length <= 0)
            return true;
        int left = 0;
        int right = length - 1;
        while(left < right){
            while(left < right){
                if((s[left] >= 'a' && s[left] <= 'z') || (s[left] >= '0' && s[left] <= '9') || (s[left] >= 'A' && s[left] <= 'Z')){
                    if(s[left] >= 'A' && s[left] <= 'Z'){
                        s[left] = s[left] - 'A' + 'a';
                    }
                     break;
                }
                left++;
            }
            while(left < right){
                if((s[right] >= 'a' && s[right] <= 'z') || (s[right] >= '0' && s[right] <= '9') || (s[right] >= 'A' && s[right] <= 'Z')){
                    if(s[right] >= 'A' && s[right] <= 'Z'){
                        s[right] = s[right] - 'A' + 'a';
                    }
                    break;
                }
                right--;
            }
            if(s[left] != s[right])
                return false;
            left++;
            right--;
        }
        return true;
    }
};

https://blog.csdn.net/helloiamclh/article/details/77932774

原文地址:https://www.cnblogs.com/ymjyqsx/p/9651404.html