my c++ 3ms solution


  • 0
    X

    class Solution {
    public:
    int strStr(string haystack, string needle) {
    if(needle.length() == 0)
    return 0;
    size_t pos = -1;
    pos = haystack.find(needle);
    if(pos == string::npos)
    {
    pos = -1;
    }
    return pos;

    }
    

    };


Log in to reply
 

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