Problem · Array
Count String Pairs With Disjoint Characters
Learn this problemProblem statement
Given an array of strings words, return the number of unordered index pairs (i, j) such that i < j and the two strings share no character.
For this exercise, assume every array index is a distinct candidate, even when two strings have equal values. Every string contains only lowercase English letters and may be empty. An empty string shares no character with any string.
Function
countDisjointCharacterPairs(words: String[]) → intExamples
Example 1
words = ["abc","def","ad","xyz"]return = 4The valid pairs are (0,1), (0,3), (1,3), and (2,3).
Example 2
words = ["a","a","b",""]return = 5The two equal a values occupy different indices. Each pairs with b and the empty string, while b also pairs with the empty string.
Example 3
words = []return = 0An empty array contains no index pair.
Constraints
0 <= words.length <= 50000 <= sum(words[i].length) <= 200000- Every string contains only lowercase English letters and may be empty.
- Each array index is counted as a distinct candidate.
More Netflix problems
- Deduplicate Homepage Content Across RowsPHONE SCREEN · Seen Aug 2026
- Longest Consecutive Identical Character RunPHONE SCREEN · Seen Aug 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Aug 2026
- Movie Billboard RotationONSITE INTERVIEW · Seen Jul 2026
- Topological Sort for Ads TasksPHONE SCREEN · Seen Jun 2026
- Command Undo Data StructureONSITE INTERVIEW · Seen Apr 2026
- Timed Cache with Sidecar CleanupONSITE INTERVIEW · Seen Apr 2026