赞
踩
题目:
题解:
- class Solution:
- def maxProduct(self, words: List[str]) -> int:
- masks = defaultdict(int)
- for word in words:
- mask = reduce(lambda a, b: a | (1 << (ord(b) - ord('a'))), word, 0)
- masks[mask] = max(masks[mask], len(word))
- return max((masks[x] * masks[y] for x, y in product(masks, repeat=2) if x & y == 0), default=0)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。