Skip to content

Practice Maximum Product of Word Lengths

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#318
LeetCode Problem

Maximum Product of Word Lengths

Problem Statement

Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0.

Source: Maximum Product of Word Lengths on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
words = ["abcw","baz","foo","bar","xtfn","abcdef"]
Output
16

# Example 2

Input
words = ["a","ab","abc","d","cd","bcd","abcd"]
Output
4

# Example 3

Input
words = ["a","aa","aaa","aaaa"]
Output
0

Constraints

2 <= words.length <= 1000
1 <= words[i].length <= 1000
words[i] consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Maximum Product of Word Lengths.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.