Knuth-Morris-Pratt

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

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(n*m) solution.