IBMOA #16
Count Similar Pairs
Estimated MediumJudge-ready
Topics (AI-labelled)HashingBits & Math
Two strings are similar if they contain the same set of letters; how many times each letter occurs does not matter. Identical strings at different indices can still form a pair, and (i,j) and (j,i) are counted only once.
Input
The first line contains n, followed by n lines of lowercase strings. 1≤n≤100000, total length ≤10^6. The original text does not exclude empty strings; this site's protocol supports an empty line representing an empty string.
Output
Output one integer, the answer.
Example 1
Input:
3
xyz
foo
of
Output:
1
Example 2
Input:
2
Output:
1
Example 3
Input:
4
ab
aab
b
ba
Output:
3
Example notes
The examples give 1, 1 and 3 respectively.
Editorial
Loading solution…