What will be the output of the following program?
import java.util.*;
public class Ways {
public static Set<String> permutationFinder(String str) {
Set<String> permutation = new HashSet<String>();
if (str == null) {
return null;
} else if (str.length() == 0) {
permutation.add("");
return permutation;
}
char initial = str.charAt(0);
String rem = str.substring(1);
Set<String> words = permutationFinder(rem);
for (String letter : words) {
for (int i = 0; i <= letter.length(); i++) {
permutation.add(charInsert(letter, initial, i));
}
}
return permutation;
}
public static String charInsert(String str, char c, int j) {
String a = str.substring(0, j);
String b = str.substring(j);
return a + b;
}
public static void main(String[] args) {
String s = "AAC";
String s1 = "ABC";
System.out.println(permutationFinder(s));
System.out.println(permutationFinder(s1));
}
}