Count Anagrams
HardLeetCodeCombinatorics & Modular Arithmetic
Approach hintTry it first, then revealHide
Words are permuted independently, so the answer is a product over words. Each word contributes a multinomial coefficient: the factorial of its length divided by the factorials of its letter counts, using modular inverses.