How can i solve this problem using backtracking?

Whether my approach to this question is wrong??

u can refer this

It is showing wrong answer

see the output there are spaces between the integer

Yes i have already added space but its not getting passed please check the code

Actually there is problem with set it will also sort the order of the sustring take a string array and then print only one of the occurence of each