Efficient Pattern Matching with the KMP Algorithm
Given two strings text and pattern, find all starting indices in text where pattern occurs as a contiguous substring. Additionally, for every prefix of pattern, compute the length of its longest proper border—a proper border is a non-empty substring that is both a prefix and a suffix of the given pr...