Count Anagrams
Try to solve the Count Anagrams problem.
We'll cover the following
Statement
You are given a string, s
, containing one or more words separated by a single space. Your task is to count and return the number of distinct anagrams of the entire string s
. As the answer may be very large, return it modulo
Note: An anagram is a word formed by rearranging the letters of another word, using all the original letters exactly once. For example, “listen” is an anagram of “silent”. Similarly, a string
t
is an anagram of strings
if thei
th
word oft
is a permutation of thei
th
word ofs
. For example, “silent era” is an anagram of “listen ear”, but "sline tear" is not.
Constraints:
s.length
s
consists of lowercase English letters and spaces' '
.There is only a single space between consecutive words.
Examples
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.