标签:
用递归进行排序 ,
用TreeSet 去重。
public class test {
public static void main(String []args){
String str = "AVCV";
TreeSet set = new TreeSet();
List list = digui(str);
System.out.println(list.size());
for(Object o :list){
set.add(o.toString());
}
}
public static List digui(String str){
List list =new ArrayList();
if(str.length() == 1){
list.add(str);
}
for(int i = 0;i < str.length();i++){
String f = str.substring(i,i+1);
String res = str.substring(0,i)+str.substring(i+1);
List px = digui(res);
for(int j = 0;j<px.size();j++){
list.add(f+px.get(j).toString());
}
}
return list;
}
}
标签:
原文地址:http://www.cnblogs.com/jjcc/p/5286776.html