bad ass for C


  • 0
    D
    int strStr(char* haystack, char* needle) {
        char * pch;
        if(!*haystack && *needle)
            return -1;
        if(!*needle && !*needle)
            return 0;
        pch =0;
        pch = strstr (haystack,needle);
        
        if(!pch)
            return -1;
        return pch-haystack;
    }
    

Log in to reply
 

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