https://leetcode.com/problems/longest-palindromic-substring/
Manacher algorithm Correlation: http://blog.csdn.net/ywhorizen/article/details/6629268
Class Solution {Public:string Longestpalindrome (string s) { char ch[2001];int p[2001]; Ch[2*s.size ()] = 0; for (int i = 0; i < 2 * s.size (); i++) { if ((i & 1) = = 1) ch[i] = s[(i>>1)]; else ch[i] = "; } int mx = 1,id = 0; P[0] = 1; int ss = 0,se = 0; for (int i = 1; ch[i]; i++) { if (MX <= i) { p[i] = 1; } else { P[i] = min (P[id * 2-i],mx-i); } while (Ch[i + p[i]] = = Ch[i-p[i]] && i >= p[i]) { p[i]++; } if (P[i] + i > mx) { id = i; MX = p[i] + i; } int ts = (I-p[i] + 1)/2; int te = (i + p[i]-2)/2; if (Te-ts >se-ss) { SE = te;ss = ts; } } Return S.substr (SS,SE-SS + 1);};
Leetcode 5 Longest palindromic Substring manacher algorithm, longest palindrome subsequence, String.substr (Start,len) Difficulty: 2