318. Maximum Product of Word Lengths
Given a string array words
, find the maximum value of length(word[i]) * length(word[j])
where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.
Example 1:
Example 2:
Example 3:
解题要点:
用位运算符的方法,把array里每个单词都运算一遍存到新array里。然后遍历一遍原有数组每个数经过位运算的值拿来比较,如没有重合,则是两个不含对方字母的单词,记录最大长度的乘积。
Last updated
Was this helpful?