




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
You can use Manacher's algorithm to get the maximum palindromic substring centered at each index
After using Manacher's for each center use a line sweep from the center to the left and from the center to the right to find for each index the farthest center to it with distance ≤ palin[center]
After that, find the maximum palindrome size for each prefix in the string and for each suffix and the answer would be max(prefix[i] * suffix[i + 1])