Algorithms
Algorithms copied to clipboard
KMP in C++
KMP is a linear time string matching algorithm. The problem involves finding all occurences where a string pattern matches a substring in a text. The naive approach to string matching involves looping over all indicies over a text string and finding the indicies where the pattern p matches the substring starting at the index.
The worst case of this approach is O(m*(n-m+1)), where m is |p| and n is |text|.