How can I decrease my running time


  • 0
    S
    if (!needle[0]) return 0;
    int i(0); 
    while (haystack[i++]&&!(haystack[i-1] == needle[0]&&haystack.substr(i1,needle.length())==needle));				
       return i!=haystack.length()+1? i-1:-1;	
    

    }


Log in to reply
 

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