Question:: Suppose We are given a string(Word),How do we efficiently find the Number of Distinct(Unique) permutaions of the given string?? As answer can get huge, print it modulo 10^9 + 7.
string contains only letters,both uppercase and lowercase (a/A to z/Z )
1<=|length of string|<=500
and Assume that no character repeats more than 10 times in the string.
Ex: s=aabcba The easiest way to find Number of distinct perm.=(6!)/(3!)(2!)(1!)
But suppose length of S is 500. Then to find the numb of distinct perm(programatically) in such case wont be easy as factorial of 500 can be very large..
Thus what is the efficient way to find the Number of Distinct(Unique) permutaions of the given string??