C++ code using find()


  • 0
    A
    class Solution {
    public:
        int strStr(string haystack, string needle) {
            std::string::size_type temp = haystack.find(needle);
            if(temp!= std::string::npos) return int(temp);
            else return -1;
        }
    };
    

Log in to reply
 

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