diff options
author | Ta180m | 2019-09-16 22:40:32 -0500 |
---|---|---|
committer | Ta180m | 2019-09-16 22:40:32 -0500 |
commit | 483cef11c1bc7372752e9f3e38efeed1706295fa (patch) | |
tree | 5d82d37561f7925a3956f755255b8ec3e28f64b9 /String | |
parent | a4913b1056bdcb010a2fddea167f8a3ce6d7b956 (diff) |
Update kmp.cpp
Diffstat (limited to 'String')
-rw-r--r-- | String/kmp.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/String/kmp.cpp b/String/kmp.cpp index 340351b..ebb50ad 100644 --- a/String/kmp.cpp +++ b/String/kmp.cpp @@ -1,4 +1,4 @@ -int KMP(string &S, string &T) { +int kmp(string &S, string &T) { // Generate KMP table vector<int> F(T.length() + 1, 0); F[0] = -1; @@ -14,6 +14,11 @@ int KMP(string &S, string &T) { if (S[i] == T[j]) { i++, j++; if (j == T.length()) return i - j; // Found match + /*if (j == T.size()) { + ret++; // Count matches + j = F[j]; + if (j < 0) i++, j++; + }*/ } else { j = F[j]; |