Dictionary Order Smaller ( Test Cases)

1st and last testcase fails in my code , Please suggest the reason .
code - https://ide.codingblocks.com/s/116440

Your approach is absolutely correct…but on hackerblocks the order of printing ans matters…
in this ques we do not have to sort the final list…instead the order of characters in respective words matter
for ex ) bac is the input output should be
bca
cba
cab

AND NOT
bca
cab
cba

so what you can do is generate all possible permutations(rec print approach) and in base case check if it is lexicographically larger than the current string…als try thinking of an approach where we do not have to check in base case and directly print our ans(HINT:draw the rec tree and prevent some calls)…i am providing you the link for better understanding

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.