import java.util.*;
public class Palindrome {
public int getLongestPalindrome(String A, int n) {
// write code here
if(A==null || n==0){
return 0;
}
int maxLen = 0;
char[] ch = A.toCharArray();
for(int i=0;i<n;++i){
//按奇回文判断
int j = 1;
int curLen = 1;
while(i-j>=0&&i+j<n&&ch[i-j]==ch[i+j]){
curLen = curLen+2;
++j;
}
if(curLen>maxLen){
maxLen = curLen;
}
//按偶回文判断
j = 0;
curLen = 0;
while(i-j>=0&&i+j+1<n&&ch[i-j]==ch[i+j+1]){
curLen = curLen+2;
++j;
}
if(curLen>maxLen){
maxLen = curLen;
}
}
return maxLen;
}
}