Share my c solution


  • 0
    F
    bool isPalindrome(char* s) {
    int p,q;
    p=0;q=strlen(s);
    if(s==NULL)return true;
    while(q>p){
        s[p]=tolower(s[p]);
        s[q]=tolower(s[q]);
        if(s[q]<'0'||s[q]>'z'||(s[q]>'9'&&s[q]<'a')){
            q--;
            continue;
        }
        if(s[p]<'0'||s[p]>'z'||(s[p]>'9'&&s[p]<'a')){
            p++;
            continue;
        }
        if(s[p]==s[q]){
            q--;p++;
        }  
        else return false;
    }
    return true;
    

    }


Log in to reply
 

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