Tle in one the test case

how can I improve my code?

The approach is very similar to that of print permutations. After generating all of the permutations all you need to do is compare your ans with the original number and print only when the ans is lexicograohically smaller than the original String.
see this: