Master advanced string algorithms: KMP failure function for O(n) pattern matching, Z-algorithm for all prefix matches, Rabin-Karp rolling hash, and suffix arrays for substring queries.
Implement KMP string search: build the failure function (LPS array) in O(m) then search in O(n). Never re-examines matched characters unlike naive search.
Add minimum characters to the front of a string to make it a palindrome. KMP trick: concatenate s + '#' + rev(s), find the LPS value at the last position.