Are we supposed to find all the permutations or is there any other approach. question link shared below

Are we supposed to find all the permutations then store it in a array than display the smaller strings. or do we have to think of any other approach. question: https://ide.codingblocks.com/s/86515

Hi
before storing the string only you can check that whether the string is smaller than the other string if yes then add them else dont.