求字符串的最大回文子串
public class Palindromic {
int maxlen,lo;public void getPali(String s,int j,int k){
while(j>=0&&k<s.length()&&s.charAt(j)==s.charAt(k)){
j--;
k++;
}
if(maxlen<k-j-1){
lo=j+1;
maxlen=k-j-1;
}
}
public String getStr(String s){
if(s.length()<2)
return s;
for(int i=0;i<s.length();i++){
getPali(s,i,i);
getPali(s,i,i+1);
}
return s.substring(lo, maxlen+lo);
}
public static void main(String[] args) {
Palindromic pa=new Palindromic();
String str=pa.getStr("baabad");
System.out.println(str);
}
}