考虑2种情况 子串为奇数和偶数 两种情况同时考虑取最大值
1.p=A+i;
char *font1=p-1;
char *next1=p+1;
2.
p1=A+i;
p2=A+i+1;
char *font2=p1-1;
char *next2=p2+1;
遍历取最大值
int getLongestPalindrome(char* A ) {
// write code here
int dp[strlen(A)];
int len=strlen(A);
char *p;
char *p1=A;
char *p2=A+1;
int res1=0;
int res2=0;
int max=0;
for(int i=0;i<len;i++)
{
p=A+i;
p1=A+i;
p2=A+i+1;
char *font1=p-1;
char *next1=p+1;
res1=1;
res2=0;
if((*p1)==(*p2))
{
res2=res2+2;
char *font2=p1-1;
char *next2=p2+1;
while(*font2==*next2)
{
res2=res2+2;
font2--;
next2++;
}
}
while(font1!=NULL&&next1!=NULL)
{
if(*font1!=*next1)
{
break;
}
else
{
font1--;
next1++;
res1=res1+2;
}
}
max=fmax(max,fmax(res1,res2));
}
return max;
}