https://ide.codingblocks.com/s/44687

RECURSION-DICTIONARY ORDER(LARGER)
Stuck At This Problem? Read Editorial Here.

Take as input str, a string. Write a recursive function which prints all the words possible by rearranging the characters of this string which are in dictionary order larger than the given string

Input Format:
Enter a string

Constraints:
None

Output Format
Display all the words larger than the string entered in separate lines

Sample Input
cab
Sample Output
cba

Hey Aryan, you are storing the strings in a set and set stores all the elements in sorted order, so by this the sequence of output strings is not printing correctly.
For eg.
input:
bca

your code’s output:
cab
cba

but correct output :
cba
cab

So, don’t use set to store the output strings.