// Builds the Longest Prefix-Suffix (LPS) array for the given pattern. // lps[i] = length of the longest proper prefix which is also a suffix in pattern[0..i] ...