Doubt regarding logic formation

could u please provide some reference videos or text for the logic formation of this question so that I could solve this question?

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.