/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param A string字符串 
 * @return int整型
 */
int getLongestPalindrome(char* A ) {
    // write code here
    int len = strlen(A);
    if(len < 2) return len;
    int* dp = (int*)malloc(sizeof(int) * len);
    int max = 1;
    for(int i = 0; i < len; i++) {
        if(i + 1 < len && A[i] == A[i + 1]) {
            int j = i + 1;
            int count = 0;
            int left = i;
            while(left >= 0 && j < len && A[left] == A[j]) {
                count++;
                j++;
                left--;
            }
            if(count * 2 > max) max = count * 2;
        }
        if(i + 2 < len && A[i] == A[i + 2]) {
            int j = i + 2;
            int count = 0;
            int left = i;
            while(left >= 0 && j < len && A[left] == A[j]) {
                count++;
                j++;
                left--;
            }
            if(count * 2 + 1 > max) max = count * 2 + 1; 
        }
        if(max / 2 > len - i) break;
    }

    return max;
}