Problem of the day
If the string is “bca”, then its permutations in lexicographically increasing order are { “abc”, “acb”, “bac”, “bca”, “cab”, “cba” }.
Given string contains unique characters.
The first line of input contains a single integer 'T', representing the number of test cases or queries to be run. Then the T test cases follow.
The first line and only line of each test case contains a string 'STR' consisting of lowercase English letters.
For every test case, the permutations of the given string are printed in lexicographically increasing order separated by space.
The output of each test case is printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= |STR| <= 9
Where |STR| is the length of the string.
Time Limit: 1 sec
3
abc
bc
c
abc acb bac bca cab cba
bc cb
c
In the 1st test case, there are 6 permutations of the given string.
In the 2nd test case, there are 2 permutations of the given string.
In the 3rd test case, there is only 1 permutation of the given string.
1
xyz
xyz xzy yxz yzx zxy zyx