Find its longest palindrome in a string
May be odd palindrome may also be even palindrome, to consider a comprehensive
Brute Force solution: (Because there is the problem of odd palindrome and even palindrome, so it is not easy to find, there is a trick is to want to add a symbol between each character in the string (any symbol, can also be a symbol in the string), and then at each location to start expanding at each end)
The answer is maximum value/2
Manacher algorithm: A character is also added between each string in a string
Palindrome Diameter: The maximum length to be extended from one position to the sides
1. Palindrome radius array: arr[], the length of the palindrome radius which can be enlarged at each position center
2. Right Palindrome right boundary R: All palindrome radius, the most right position
Start position is-1
3. Palindrome right boundary of the center of the current palindrome right boundary reached the far right, is the location of the Center for the expansion
Algorithm:
1. The current position is I possibility 1:i is not in the palindrome right boundary R, then uses the violent expansion
Possibility 2:i in the palindrome right boundary R, and I about the palindrome right center of Symmetry position I ' palindrome Center radius all in L and R inside
The radius of the Palindrome area at the I position is the same as I '
Possibility 3:
Possibility 4:
Data structure--manacher algorithm (longest palindrome substring)