How to set it in a lexicographical order?
@Ashish940
Sorting your generated permutations is easy. Create a vector of strings in global scope.
vector < string > v ;
Instead of printing the permutations in Line No. 6 , push them into this vector.
In the main( ) , after all your recursive calls are done , you have vector v ready with all your permutations.
Call sort( ) of < algorithm > on this vector.
sort( v.begin() , v.end() ) ;
Now just simply print the contents of this vector using a loop.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.