> For the complete documentation index, see [llms.txt](https://cai-sen-se.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cai-sen-se.gitbook.io/leetcode/201-400/318.-zui-da-dan-ci-chang-du-cheng-ji.md).

# 318.最大单词长度乘积

<https://leetcode-cn.com/problems/maximum-product-of-word-lengths/>

## 一、暴力

用双指针将所有字符串两两比较，转为set求交集判断是否有重合字符。最后记得用原串长度计算乘积（串中可能有重复字符）

```python
class Solution:
    def maxProduct(self, words: List[str]) -> int:
        res = 0
        n = len(words)
        for i in range(n):
            for j in range(i+1, n):
                setI = set(words[i])
                setJ = set(words[j])
                if not (setI & setJ):
                    res = max(res, len(words[i])* len(words[j]))
        return res
```
