Given a string A. Find the rank of the string amongst its permutations sorted lexicographically.
Assume that no characters are repeated.
Note: The answer might not fit in an integer, so return
your answer % 1000003
1 <= |A| <= 1000
First argument is a string A.
Return an integer denoting the rank of the given string.
A = "acb"
A = "a"
Given A = "acb". The order permutations with letters 'a', 'c', and 'b' : abc acb bac bca cab cba So, the rank of A is 2.
Given A = "a". Rank is clearly 1.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.