@@ -0,0 +1,1814 @@
+/*%0A Given a string array words, find the maximum value of length(word%5Bi%5D) * length(word%5Bj%5D) 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.%0A%0AExample 1:%0A%0AGiven %5B%22abcw%22, %22baz%22, %22foo%22, %22bar%22, %22xtfn%22, %22abcdef%22%5D%0AReturn 16%0AThe two words can be %22abcw%22, %22xtfn%22.%0A%0AExample 2:%0A%0AGiven %5B%22a%22, %22ab%22, %22abc%22, %22d%22, %22cd%22, %22bcd%22, %22abcd%22%5D%0AReturn 4%0AThe two words can be %22ab%22, %22cd%22.%0A%0AExample 3:%0A%0AGiven %5B%22a%22, %22aa%22, %22aaa%22, %22aaaa%22%5D%0AReturn 0%0ANo such pair of words. %0A*/%0A%0Aimport java.util.*;%0A%0Apublic class MaximumProductofWordLengths %7B%0A%09public static int maxProduct(String%5B%5D words) %7B%0A        if(words.length %3C= 1) return 0;%0A        int  L = words.length;%0A        int res = 0;%0A        for(int i = 0; i %3C L; i++)%7B%0A            for(int j = i+1; j %3C L; j++)%7B%0A                if(hasCommonLetter(words%5Bi%5D, words%5Bj%5D) == false)%7B%0A                    res = Math.max(words%5Bi%5D.length()*words%5Bj%5D.length(), res);%0A                %7D%0A            %7D%0A        %7D%0A        return res;%0A        %0A    %7D%0A    %0A    public static boolean hasCommonLetter(String a, String b)%7B%0A        int%5B%5D arr = new int%5B26%5D;%0A        for(int i = 0; i %3C a.length(); i++)%7B%0A            int p = a.charAt(i) - 'a';%0A            arr%5Bp%5D = 1;%0A        %7D%0A        for(int i =0; i %3C b.length(); i++)%7B%0A            int p = b.charAt(i) - 'a';%0A            if(arr%5Bp%5D == 1) return true;%0A        %7D%0A        return false;%0A    %7D%09%0A%09%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String%5B%5D words = new String%5B%5D %7B%22abcw%22, %22baz%22, %22foo%22, %22bar%22, %22xtfn%22, %22abcdef%22%7D;%0A        System.out.println(%22Words: %22);%0A%09%09for(int i=0; i %3C words.length; i++)%7B%0A%09%09%09System.out.print(words%5Bi%5D + %22 %22);%0A%09%09%7D%0A        System.out.println();%0A%09%09int res = maxProduct(words);%0A        System.out.println(%22Maximum products: %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

maximum product of word