Knuth-Morris-Pratt

The Knuth-Morris-Pratt (KMP) algorithm is an algorithm for finding a pattern in a string.

Time Complexity
The algorithm's time complexity is $$O(n + m)$$ if $$n$$ and $$m$$ are the lengths of the pattern and the text. This is better than the trivial $$O(nm)$$ solution.