public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param A string字符串
* @return int整型
*/
int getLongestPalindrome(string A) {
if (A.size() < 2)
return A.size();
int maxlen = 0;
for (int i=0; i<A.size()-1; i++){
help(A, i, i, maxlen);
help(A, i, i+1, maxlen);
}
return maxlen;
// write code here
}
void help(string A, int left, int right, int& maxlen){
while(left>=0 && right<A.size() && A[left]==A[right]){
left--;
right++;
}
if (maxlen < right - left - 1){
maxlen = right - left - 1;
}
}
};
```https://www.cnblogs.com/grandyang/p/4464476.html