Ruby math combinatorics RT 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# @param {String} s\n# @return {Integer}\ndef count_anagrams(s)\n  mod = 10 ** 9 + 7\n  \n  fact = -> (i, max_i = nil) { max_i ? ((max_i + 1)..i).inject(:*) : (1..i).inject(:*) } \n\n  s.split.inject(1) do |acc, word|\n    if word.chars.uniq.size == 1\n      cnt = 1\n    else\n      chars = word.chars.inject(Hash.new(0)) { |h, e| h[e] += 1 ; h }.values.reject {|k| k <=1}\n      cnt = fact.call(word.size, chars.max)\n      chars.delete_at(chars.index(chars.max)) if chars.max\n      chars.each { |k| cnt /= fact.call(k)}    \n    end\n    acc * cnt  % mod\n  end  \nend\n```
['Math', 'Ruby']