#include<iostream>
#include<cstring>
#include <algorithm>
using namespace std;
int *next;
int caculate_rear(string s) {
return 0;
}
int caculate_second_same(string s) {
return 0;
}
void GetNext(string p, int* next) {
int pLen = p.size();
next[0] = -1;
int k = -1;
int j = 0;
while (j <=pLen - 1)
{
//p[k]表示前缀,p[j]表示后缀
if (k == -1 || p[j] == p[k])
{
//J一定会被赋值
next[j + 1] = k + 1;
k++; j++;
}
else
{
k =next[k];
}
}
}
kmp啊啊啊
最新推荐文章于 2024-09-10 00:01:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)