Subsequences in lexicographical order

ques link ----- https://hack.codingblocks.com/contests/c/917/73
ans link ----- https://ide.codingblocks.com/s/113444
how do i convert them in lexicographical order

@S19LPPP0192
You can sort your outputs by inserting them in a vector of strings declared in global.
vector< string > v ;
Instead of printing your output in Line No. 8 , push the osf string into the vector.
v.push_back(osf);

Now once all your recursive calls are done and you are back in main( ) , call sort( ) on this vector.
sort(v.begin() , v.end() ) ;

Now all your subsequences are sorted. Just print them using a loop.

where will that final loop will terminate? I have made some changes acc to your instructions .

you can check my code in previous id only

output is coming correct but hacker blocks is showing wrong answer