Given a string arraywords, find the maximum value oflength(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:
Given["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]
Return16
The two words can be"abcw", "xtfn".
免得字符串排序判断是否有相同字符, 采用二进制数值的方式, 每个字符串做多有26种字幕, 每个字母对应一个二进制位, 每个字符串就是一个数字, 最后数字两两与, 如果==0 , 则证明没有相同字符。 然后再求最大乘积。
网友评论