class Solution:
def maxProduct(self, words: List[str]) -> int:
masks = [reduce(lambda a, b: a | (1 << (ord(b) - ord('a'))), word, 0) for word in words]
return max((len(x[1]) * len(y[1]) for x, y in product(zip(masks, words), repeat=2) if x[0] & y[0] == 0), default=0)
最大单词长度乘积
最新推荐文章于 2024-06-13 23:55:30 发布