package com.mbc.meituan;
//第5题实现组合输出并且去掉重复元素
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
public class Zuhe {
public static void permutation(char[]ss,int i){
HashSet<String> res=new
HashSet<String>();
ArrayList<String> res1=new
ArrayList<String>() ;
if(ss==null||i<0 ||i>ss.length)
{
return;
}
if(i==ss.length)
{
res1.add(new String(ss));
}
else
{
for(int j=i;j<ss.length;j++)
{
char temp=ss[j];
ss[j]=ss[i];
ss[i]=temp;
permutation(ss,i+1);
temp=ss[j];
ss[j]=ss[i];
ss[i]=temp;
}
}
for(int l=0;l<res1.size();l++)
{
res.add(res1.get(l));
}
for(Iterator<String>
it=res.iterator();it.hasNext();)
{
System.out.println(it.next());
}
}
public static void main(String args[]){
String s="see";
char []ss=s.toCharArray();
permutation(ss,0);
}
}