2-line C++ solution(6ms)


  • -9
    H
    class Solution {
    public:
        int strStr(char *haystack, char *needle) {
            string a(haystack);
            return a.find(needle)==a.npos?-1:a.find(needle);
        }
    };
    

    :)


Log in to reply
 

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