Introduction
KMP is a string searching algorithm using pattern searching. If subpattern appear more than once KMP is effecient. If two adjacent letters match, it improves the count of longest proper prefix and suffix count. Otherwise it reduces to previous value. Once full pattern has been found, for the next character match, we go to previous value of lps, so that we only need to compare single character. Therefore time complexity of KMP algorithm is O(n)