A banner is printed by arranging all the letter tiles of a given word in a row. Repeated letters are indistinguishable, so two arrangements are the same when they read as the same string. Count the number of distinct strings that can be formed by permuting all the tiles of the word. Report the count modulo 1000000007.
A single line: a non-empty word made of lowercase English letters.
A single integer: the number of distinct arrangements, modulo 1000000007.
Example 1
Input
aab
Expected
3
Explanation
The distinct arrangements of a,a,b are aab, aba, baa = 3.
Example 2
Input
abc
Expected
6
Explanation
All 3 letters are distinct, so there are 3! = 6 arrangements.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →