Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Maximum Product of Word Lengths

Medium

Topics
ArrayStringBit Manipulation

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 ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access