Clean and fast c solution (3ms)


  • 0
    T
    int removeDummy(char *s)
    {
        int c = 0;
        int i;
        for(i=0;s[i];i++)
            if(isalpha(s[i])||isdigit(s[i]))
                s[c++] = tolower(s[i]);
        s[c] = '\0';
        return c;
    }
    bool isPalindrome(char* s) {
        int len = removeDummy(s);
        for(int i=0; i<len/2; i++) {
            if(s[i]!=s[len-i-1])
                return false;
        }
        return true;
    }
    

Log in to reply
 

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