Tricky Permutation

what needs to be corrected in the below code such that it prints the data in the lexicographical order.
I am not getting the duplicate while using the set but the answer is not coming in lexicographical order.

Below is the link, kindly check and correct the python code

hello @mridulpant

sort ur input string and then apply the logic.

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.