Prefix-Suffix Palindrome (Hard version)
HardRating 1800CodeforcesString Algorithms (KMP, Z, Hashing)
Approach hintTry it first, then revealHide
First strip the longest outer layer where s[i] == s[n-1-i]. In the remaining middle, find its longest palindromic prefix and longest palindromic suffix with the prefix function, and keep the longer one.