Chapter 4. 串

Chapter 4. 串 考点 KMP 算法 求 next 数组 计算前后缀公共最大长; 将计算结果右移一位,最左位补 -1 ; 所有位 +1。 求 nextval数组 if ( s[next[j]] == s[j] ) { next[j] = next[next[j]] } next 数

acautomaton 发布于 2024-08-18

Section 11.Knuth-Morris-Pratt

一、暴力求解! string s, p; //长度为n的模式串s和长度为m的模版串p for (int i = 1; i <= n; i++) { bool flag = true; for (int j = 1; j <= m; j++) { if (s[i - j + 1] != p

acautomaton 发布于 2022-01-23