My 5ms c code solution


  • 0
    L
    bool isPalindrome(char* s) {
    int n=strlen(s);
    int p,q;
    if(s==0)
    return true;
    p=0,q=n-1;
    while(p<q)
    {
        while((*(s+p)<48||*(s+p)>57)&&(*(s+p)<65||*(s+p)>90)&&(*(s+p)<97||*(s+p)>122)&&p<n-1)
        p++;
        while((*(s+q)<48||*(s+q)>57)&&(*(s+q)<65||*(s+q)>90)&&(*(s+q)<97||*(s+q)>122)&&q>0)
        q--;
        if(p==n-1&&q==0)
        return true;
        if((*(s+p)!=*(s+q))&&(abs(*(s+p)-*(s+q))!=32))
        return false;
        p++,q--;
    }
    return true;
    

    }


Log in to reply
 

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