Bit Manipulation - Maximum Product of Word Lengths
The following code attempts to find the maximum product of word lengths with no common letters. Which line contains a subtle bug that causes incorrect results on some inputs?
```python
def maxProduct(words):
n = len(words)
masks = []
for word in words:
mask = 0
for ch in word:
mask |= 1 << (ord(ch) - ord('a') + 1)
masks.append((mask, len(word)))
masks.sort(key=lambda x: x[1], reverse=True)
max_prod = 0
for i in range(n):
if masks[i][1] * masks[i][1] <= max_prod:
break
for j in range(i + 1, n):
if masks[i][1] * masks[j][1] <= max_prod:
break
if (masks[i][0] & masks[j][0]) == 0:
max_prod = max(max_prod, masks[i][1] * masks[j][1])
return max_prod
```
