字符串匹配 我的方法 vs KMP算法(看不懂)

示例 1:
输入: haystack = "hello", needle = "ll"
输出: 2

示例 2:
输入: haystack = "aaaaa", needle = "bba"
输出: -1

我的方法:
class Solution {
public:
    int strStr(string haystack, string needle) {
        int hay_size=haystack.size();
        int nee_size=needle.size();
        if(nee_size==0){
            return 0;
        }
        if(hay_size

你可能感兴趣的:(字符串匹配 我的方法 vs KMP算法(看不懂))