4 ms 10 line in c


  • 0
    J
    bool isPalindrome(char* s) {
        int begin = 0; 
        int end = strlen(s); 
        while (begin < end) {
            if ( !isalnum(s[begin]) ) { begin++; continue; }
            if ( !isalnum(s[end])   ) { end--;   continue; }
            if ( toupper(s[begin++]) != toupper(s[end--]) ) return false; 
        }
        return true;
    }

Log in to reply
 

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