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