Shortest Palindrome
HardLeetCodeString Algorithms (KMP, Z, Hashing)
Approach hintTry it first, then revealHide
The final prefix-function value of s + '#' + reverse(s) is the length of the longest palindromic prefix of s. Prepend the reverse of the remaining suffix.