package LeetCode.String.HuiWen; import java.util.ArrayList; public class Solution { public String longestPalindrome(String s) { int maxIndex = 0; ArrayList str = new ArrayList<>(); //求出所有子串(不去重) for(int i=0;i (str.get(maxIndex)).length()) maxIndex = i; } return str.get(maxIndex); } }