Valid Palindrome


  • 0
    B

    class Solution {
    public:
    bool isPalindrome(string s) {

        int start=0;
        int end=s.size()-1;
        
        while(start<=end)
        {
    		while(isalpha(s[start])==false)
    		{
    			start++;
    		}
    		while(isalpha(s[end])==false)
    		{
    			end--;
    		}
    
    		if(start<=end&&start<s.size()&&end>=0)
    		{
    			if((s[start]+32==s[end])||(s[end]+32==s[start])||(s[start]==s[end]))
                {
                    start++;
                    end--;
                   
                }
                else
                {
                    return false;
                }
    		}
    
        }
        
        return true;
        
    }
    
    bool isalpha(char ch)
    {
        if('a'<=ch<='z'||'A'<=ch<='Z')
            return true;
        return false;
    }
    

    };

    why "a." cann't pass ! in my owner computer it was true, when on three it was false?
    the code is sample ,I just cant undestand why it wont work!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.