Maximum Product of Word Lengths
class Solution(object):
def maxProduct(self, words):
"""
:type words: List[str]
:rtype: int
"""
es = []
for w in words:
es.append(sum(1 << (ord(c)-ord('a')) for c in set(w))) # error 1: not using set(w), wrong ["a","aa","aaa","aaaa"]
maxLen = 0
for i in xrange(len(words)-1):
for j in xrange(i+1, len(words)):
if not (es[i] & es[j]):
if maxLen<len(words[i])*len(words[j]):
maxLen = len(words[i])*len(words[j])
return maxLen