I am unable to solve this problem
my output is :
[ , a , 97 , b , ab , 97b ]
Code is:::::::::::>>
package Recursion.RecursionGet;
import java.util.ArrayList;
public class GetSubSequence {
public static void main(String[] args) {
System.out.println(getSS("def"));
System.out.println(printSSWAscii("ab"));
}
public static ArrayList<String>getSS(String str)
{
if (str.length()==0)
{
ArrayList<String> base=new ArrayList<>();
base.add(" ");
return base;
}
char cc=str.charAt(0);//get first character a
String ros=str.substring(1);//get bc
ArrayList<String>myResult=new ArrayList<>();
ArrayList<String>recResult=getSS(ros);
for (int i=0;i<recResult.size();i++)
{
myResult.add(recResult.get(i));
myResult.add(cc+recResult.get(i));
}
return myResult;
}
public static ArrayList<String > printSSWAscii(String str) {
if (str.length() == 0) {
ArrayList<String> base=new ArrayList<>();
base.add(" ");
return base;
}
char c = 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++)
{
myResult.add(recResult.get(i));
myResult.add(c+recResult.get(i));
myResult.add((int) c+recResult.get(i));
}
return myResult;
}
}