Longest palindromic Substring longest palindrome substring
Given a string S, find the longest palindromic substring in s. The maximum length of S is assume, and there exists one unique longest palindromic substring.
General practice, Dynamic Planning O (n^2) is able to directly produce results, the length from small to large arrangement, you can record the maximum value of the edge motion.
Shortest palindrome Shortest palindrome generation
Given A string S, you is allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.
For example:
Given "aacecaaa"
, return "aaacecaaa"
.
Given "abcd"
, return "dcbabcd"
.
Common practice, that is to find the longest palindrome from scratch, the complexity of O (n^2);
In fact, the classic algorithm for finding the longest palindrome substring centered on a point is the manacher algorithm, with the complexity of O (N), which can be used to find substrings centered on each point in the string. The Manacher algorithm can refer to http://blog.csdn.net/ggggiqnypgjg/article/details/6645824/
[Classic] palindrome problem (iii)