We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2dadbf7 commit cd4222bCopy full SHA for cd4222b
strings/knuth_morris_pratt.cpp
@@ -54,6 +54,10 @@ std::vector<int> getFailureArray(const std::string &pattern) {
54
* \returns `false` if pattern was not found
55
*/
56
bool kmp(const std::string &pattern, const std::string &text) {
57
+ if (pattern.empty()) {
58
+ return true;
59
+ }
60
+
61
int text_length = text.size(), pattern_length = pattern.size();
62
std::vector<int> failure = getFailureArray(pattern);
63
0 commit comments