This question evaluates proficiency in string-processing algorithms, sliding-window techniques, efficient set or bitmask representations, and combinatorial pair counting under strict time and space constraints.
Given a string s, find the length of the longest contiguous substring that contains no repeated characters.
s
1 <= len(s) <= 2e5
; ASCII characters.
Given a list of strings words, count the number of unique unordered pairs (i, j) with i < j such that words[i] and words[j] share no common characters.
c
that appears in both strings.
Input: ["apple", "banana", "peach", "kiwi"]
Valid unique pairs include:
Design an algorithm with time complexity O(n log n) (or better) where n = len(words).
words
1 <= n <= 2e5
; each word length up to
1e3
; characters are lowercase
a
–
z
(state any additional assumptions you need).