A spice workshop labels each blend with a short code made of lowercase English letters. Two codes belong to the same anagram family if one can be rearranged into the other (they use exactly the same letters with the same multiplicities). Count how many distinct anagram families appear among the given codes.
Line 1: an integer n, the number of blend codes.
Line 2: n space-separated codes, each 1 to 20 lowercase English letters.
A single integer: the number of distinct anagram families.
Example 1
Input
3 cat act dog
Expected
2
Explanation
cat and act use the same letters, so they form one family; dog forms a second family. That is 2 families.
Example 2
Input
4 ab ba abc cba
Expected
2
Explanation
ab and ba are one family; abc and cba are another. That is 2 families.
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 →