Tricky Permutations TLE

All test cases are working fine except for the last one it is showing tle
code link : https://ide.codingblocks.com/s/102391

Hi himanshu
your code is giving TIME LIMIT EXCEED for String greater than length 9.
Try to optimise your code more.

Can u provide with me the updated code as i have tried everything but still my code is giving tle.

Hi Himanshu,
Your Code Time Complexity is roughly n!*logn!.
for Input str length 10 the code will do 10!*log 10! calculations per sec which is quite huge.
Try to optimize your code and revert back with the optimised Code.

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.