1 String ros = str.substring(1); ( when str = “c” ) doesn’t returns " " instead it returns “”.
2 for(int i = 0 ; i< recResult.size(); i++)
{
myResult.add(recResult.get(i));
recResult.add(cc+recResult.get(i));
}
when recResult is Returned for first time value in it = [" “]
when c +” " it gives "c " , so there will be an extra space in every subsequence .
Btw I’m getting Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Unknown Source)
at java.lang.String.(Unknown Source)
at java.lang.StringBuilder.toString(Unknown Source)
at Recursion.RecursionContinued.getSS(RecursionContinued.java:27)
at Recursion.RecursionContinued.getSS(RecursionContinued.java:23)
at Recursion.RecursionContinued.getSS(RecursionContinued.java:23)
at Recursion.RecursionContinued.main(RecursionContinued.java:9)