题解 | #最长回文子串#
最长回文子串
http://www.nowcoder.com/practice/12e081cd10ee4794a2bd70c7d68f5507
import java.util.*;
public class Main {
public static int value = Integer.MAX_VALUE;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int max =0;
for(int i=0;i<s.length();i++){
for(int j = s.length();j>i;j--){
String judege = s.substring(i,j);
if(isJudge(judege)){
max = Math.max(max,j-i);
}
}
}
System.out.println(max);
}
public static boolean isJudge(String s){
return s.equals(new StringBuilder(s).reverse().toString());
}
}
public class Main {
public static int value = Integer.MAX_VALUE;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int max =0;
for(int i=0;i<s.length();i++){
for(int j = s.length();j>i;j--){
String judege = s.substring(i,j);
if(isJudge(judege)){
max = Math.max(max,j-i);
}
}
}
System.out.println(max);
}
public static boolean isJudge(String s){
return s.equals(new StringBuilder(s).reverse().toString());
}
}