LeetCode 28 Implement strStr()

来源:互联网 发布:南华大学网络教育 编辑:程序博客网 时间:2024/05/16 09:12

LeetCode 28 Implement strStr()

#include <string>using namespace std;class Solution {public:    int strStr(string haystack, string needle) {        int position;        if (haystack.find(needle) != string::npos)            position = haystack.find(needle);        else            position = -1;        return position;    }};