How to print sequence in reverse order

how to print my sequence in reverse manner like for abc output should br c,b,bc,a,ac,ab,abc

Hey, you can do it using simple recursion make the first recursive call without adding the character and make the second recursive call by adding the character in answer as shown in this code below :

char ch = quest.charAt(0);
String ros = quest.substring(1);
subsequence(ros, ans + "");
subsequence(ros, ans + ch);

and in base case when string’s length become 0 just print the ans.