Knuth–Morris–Pratt algorithm

Algorithm for finding sub-text location(s) inside a given sentence in Big O(n) time From Wikipedia, the free encyclopedia