# Sorted Permutation Rank With Repeats
https://www.interviewbit.com/problems/sorted-permutation-rank-with-repeats
If you have not solved RANK problem, we advice you to take a look into that.
If you have, lets move forward here.
Enumerating all permutations and matching with the current one is going to be exponential.
Lets start by looking at the first character.
If the first character is X, all permutations which had the first character less than X would come before this permutation when sorted lexicographically.
Number of permutation with a character C as the first character = number of permutation possible with remaining N-1 character = (N-1)! / (p1! * p2! * p3! ... ) where p1, p2, p3 are the number of occurrences of repeated characters.
For example, number of permutations possible with 3 'a' and 3 'b' is 6! / 3! 3! = 20
Can you use the above information to get the rank of the current permutation ?
This file has been truncated. show original