Given a string, find the rank of the string amongst its permutations sorted lexicographically.
Return 0 if the characters are repeated in the string.
Input : 'acb'
Output : 2
The order permutations with letters 'a', 'c', and 'b' :
The answer might not fit in an integer, so return your answer % 1000003
The first line of input contains an integer T denoting the number of test cases. Each test case consist of a string in 'lowercase' only in a separate line.
Print the rank of the string amongst its permutations.
1 ≤ T ≤ 50
1 ≤ |s| ≤ 15
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.