public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
ArrayList a= getpermutation(sc.nextLine());
ArrayList b=replaceduplicate(a,0);
String c[]=new String[b.size()];
c=b.toArray©;
printArray©;
}
public static ArrayList getpermutation(String p)
{
if(p.length()==0)
{
ArrayList bc=new ArrayList<>();
bc.add("");
return bc;
}
ArrayList mr=new ArrayList<>();
String cs=p.substring(0, 1);
String rs=p.substring(1);
ArrayList rr=getpermutation(rs);
for(String i:rr)
{
for(int j=0;j<=i.length();j++)
{
mr.add(i.substring(0,j) + cs +i.substring(j));
}
}
return mr;
}
public static ArrayList replaceduplicate(ArrayList list,int counter)
{
if(counter < list.size()){
if(list.contains(list.get(counter))){
list.remove(list.lastIndexOf(list.get(counter)));
}
replaceduplicate(list, ++counter);
}
return list;
}
public static void printArray(String []words)
{
for(int i = 0; i < words.length; ++i) {
for (int j = i + 1; j < words.length; ++j) {
if (words[i].compareTo(words[j]) > 0) {
String temp = words[i];
words[i] = words[j];
words[j] = temp;
}
}
for(int i = 0; i < words.length; i++) {
System.out.println(words[i]);
}
}
}
this is my solution what is problem in this solution