318. Maximum Product of Word Lengths

网友投稿 531 2022-11-11

318. Maximum Product of Word Lengths

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: Given [“abcw”, “baz”, “foo”, “bar”, “xtfn”, “abcdef”] Return 16 The two words can be “abcw”, “xtfn”.

Example 2: Given [“a”, “ab”, “abc”, “d”, “cd”, “bcd”, “abcd”] Return 4 The two words can be “ab”, “cd”.

Example 3: Given [“a”, “aa”, “aaa”, “aaaa”] Return 0 No such pair of words.

class Solution { public int maxProduct(String[] words) { int len = words.length; if(len <=1 ) return 0; int[] mask = new int[len]; for(int i=0;i

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:173. Binary Search Tree Iterator
下一篇:关于微服务使用Dubbo设置的端口和server.port的区别
相关文章

 发表评论

暂时没有评论,来抢沙发吧~