← 返回 netflix 的题目列表Count Pairs of Strings with No Common Characters
类型:online_judge
Given an array words of n strings, count the number of index pairs (i, j) such that:
0 <= i < j < n
words[i] and words[j] share no character.
Every string contains only lowercase English letters.
Example:
Input: words = ["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]
Output: 3
Explanation: The valid pairs are (0, 2), (1, 4), and (3, 4).
Constraints:
1 <= n <= 10^5
1 <= len(words[i]) <= 10^5
The sum of all string lengths is at most 10^6.
Example
Input
6
abcw
baz
foo
bar
xtfn
abcdef
Output
3