This thread will introduce an O(N) solution, where N is the summation of all lengths of the strings.
Notations:
For a string
s
, let N(s)
be the length of the string s
. Let the set F(s)
be all subsets of the set of characters that do not appear in the string s
.
Example,
s = "abcefghijlmnopqrstuvwxyz"
(this string contains all characters from 'a'
to 'z'
except 'd'
and 'k'
)
N(s) = 24
(262=24)
F(s) = {"", "d", "k", "dk"}
(powerset of "dk"
)
We can get F(s)
in O(N(s)
) time. The cardinality of F(s)
is no more than 2^26. That is, F(s)
 = O(1).
Additionally, we maintain an unordered_map m
, whose keys are the subsets of the alphabet, and the corresponding value is the largest length of strings that does not contains the characters in the entry. The size of m
is 2^26 = O(1).
Algorithm Outline:
We only need two O(N) passes to solve this problem:

Pass 1:
For each strings
, we need O(N(s)
) time to calculateF(s)
, then need O(1) time to update the entryf
ofF(s)
in a map bym[f] = max(m[f], N(s))
. 
Pass 2:
For each strings
, we need O(N(s)
) time to calculateF(s)
, then need O(1) time to find maximum ofm[f]
, wheref
belongs toF(s)
. Here we get a potential candidate of result:N(s) * max(m[f])
. Then update the result accordingly byresult = max(result, N(s) * max(m[f]))
.
Complexities:

Time: O(N)

Space: O(1)