串的模式匹配算法-KMP算法

最简单的算法就不说了,直接上KMP,时间复杂度是 O(n+m)。 1.next数组 2.kmp过程 这一段和next数组的构建很相似。 #include<iostream> #include<cstring> using namespace std; int next[105]; void next_int(string t){ int lent=t.length(); int j
相关文章
相关标签/搜索