Msharma
BAN USERHere is my another attempt with String:
public class PrintSubsequences {
public static void printStringSubsequnces(String str, int index, char biggestNumber){
if(index < str.length()){
if(str.charAt(index) >= biggestNumber){
System.out.print(str.charAt(index));
printStringSubsequnces(str, index+1, str.charAt(index));
}else
printStringSubsequnces(str, index+1, biggestNumber);
}
}
public static void printStringSequenceHelper(String str, int index){
if(index < str.length()){
printStringSubsequnces(str, index, str.charAt(index));
System.out.print("\n");
printStringSequenceHelper(str, index+1);
}
}
public static void main(String[] args){
PrintSubsequences.printStringSequenceHelper("54782369862345", 0);
}
}
Well I could not answer correctly at the time of test but the very next morning I did it following way:
- Msharma April 17, 2012