Problem Link :Contest Practice
Given a string, print the number of substrings of it that are pallindromes.
The problem is a direct application of manacher algorithm. This algorithm finds the length of pallindromic substring centered at every characters in the string. For example, consider the string aba. Manacher’s algorithm converts the string to the form #a#b#a#. So length of longest pallindrome centered around a is 1, around b is 3 (aba), and around a is 1. Similarly, length of longest pallindrome around the # are also found (for even length pallindromes). Now, the number of pallindromic substring is the ceiling function of each length divided by 2.
See setter solution for implementation.
You can read about Manacher’s algorithm here.