public static String maxSameStr(String str) { String nstr = ""; if (str == null || str.length() == 0) return nstr; ArrayListlist = new ArrayList<>(); for (int i = 0; i < str.length(); i++) { for (int j = i + 1; j <= str.length(); j++) { String s = str.substring(i, j); if (list.contains(s)) { if (s.length() > nstr.length()) nstr = s; } list.add(s); } } return nstr; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)