Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions strings/knuth_morris_pratt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ std::vector<int> getFailureArray(const std::string &pattern) {
* \returns `false` if pattern was not found
*/
bool kmp(const std::string &pattern, const std::string &text) {
if (pattern.empty()) {
return true;
}

int text_length = text.size(), pattern_length = pattern.size();
std::vector<int> failure = getFailureArray(pattern);

Expand Down
Loading