package DSA;
import java.util.*;
public class Getsequence {
public static void main(String[] args) {
System.out.println(getss("ab"));
}
public static ArrayList<String> getss(String str) {
if (str.length() == 0) {
ArrayList<String> baseResult = new ArrayList();
baseResult.add(" ");
return baseResult;
}
char cc = str.charAt(0);
String ros = str.substring(1);
ArrayList<String> myResult = new ArrayList();
ArrayList<String> recResult = getss(ros);
for (int i = 0; i < recResult.size(); i++) {
for (int j = 0; j < str.length(); j++) {
char character = str.charAt(j);
int ascii = (int) character;
myResult.add(ascii + cc + recResult.get(i));
}
myResult.add(recResult.get(i));
myResult.add(cc + recResult.get(i));
}
return myResult;
}
}