Problem of the day
There will only be distinct characters in the given string.
First line contains an integer ‘T’ denoting the number of test cases.
First and the only line of the test case contains a string ‘S’.
Output contains an integer ‘X’ denoting the Lexicographic Permutation Rank of the given string.
You don’t need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 25
1 <= |S| <= 20
‘a’ <= S[i] <= ‘z’
Time Limit: 1 sec.
2
abc
cba
1
6
All permutations with string abc in the lexicographical order will be “abc”, “acb”, “bac”, “bca”, “cab”, “cba”.
Test Case 1:
“abc” will have the rank 1.
Test Case 2:
“cba” will have rank 6.
2
coding
string
100
598