C++ 2 lines Effective solution


  • 0
    V
      int strStr(string haystack, string needle) {
            auto res = haystack.find(needle);
            return (res!=string::npos? int(res):-1);
        }
    

Log in to reply
 

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