Maximum Product of Word Lengths
Medium
Topics
Given an array of strings words, return the maximum value of length(words[i]) * length(words[j]) where the two words share no common letters. If no such pair exists, return 0.
Example 1
Input: words = ["abcw","baz","foo","bar","xtfn","abcdef"] Output: 16 Explanation: "abcw" and "xtfn" share no letters: 4 * 4 = 16.
Example 2
Input: words = ["a","aa","aaa","aaaa"] Output: 0
Constraints
- 2 <= words.length <= 1000
- 1 <= words[i].length <= 1000
- words[i] consists of lowercase English letters.
Run ⌘' · Submit ⌘⏎