Recursion dictionary order small

My Recursive Code is undergoing TLE

@arjunsabu99,

One optimization technique you can use is that you can convert the string to a char array and sort the char array in ascending order. That way you can easily compute the strings and print the required answer.

Here, 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.