第一题就是普通的lru,代码未保存,就略了 第二题将模式串n()的形式拆分出来,然后将待匹配串处理成A+N的形式,跑一遍kmp即可 #include <iostream> #include <string> #include <stack> #include <cstring> using namespace std; int nxt[1000005]; void getNext(const char *s, int len) { nxt[0] = 0; int k = 0; for (int i = 1; i <...