美文网首页
318. Maximum Product of Word Len

318. Maximum Product of Word Len

作者: 我是你的果果呀 | 来源:发表于2016-12-11 03:58 被阅读0次

    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 , 则证明没有相同字符。 然后再求最大乘积。

    相关文章

      网友评论

          本文标题:318. Maximum Product of Word Len

          本文链接:https://www.haomeiwen.com/subject/jeoumttx.html