package leetcode;

/**
 * https://leetcode.com/problems/maximum-product-of-word-lengths/
 */
public class Problem318 {
    public int maxProduct(String[] words) {
        // TODO:
        return 0;
    }

    public static void main(String[] args) {
        Problem318 prob = new Problem318();
        System.out.println(prob.maxProduct(new String[]{"abcw", "baz", "foo", "bar", "xtfn", "abcdef"})); // 16
        System.out.println(prob.maxProduct(new String[]{"a", "ab", "abc", "d", "cd", "bcd", "abcd"})); // 4
        System.out.println(prob.maxProduct(new String[]{"a", "aa", "aaa", "aaaa"})); // 0
    }
}

@@ -168,440 +168,621 @@
     
-// TODO:%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem318 prob = new Problem318();%0A        System.out.println(prob.maxProduct(new String%5B%5D%7B%22abcw%22, %22baz%22, %22foo%22, %22bar%22, %22xtfn%22, %22abcdef%22%7D)); // 16%0A        System.out.println(prob.maxProduct(new String%5B%5D%7B%22a%22, %22ab%22, %22abc%22, %22d%22, %22cd%22, %22bcd%22, %22abcd%22%7D)); // 4%0A        System.out.println(prob.maxProduct(new String%5B%5D%7B%22a%22, %22aa%22, %22aaa%22, %22aaaa%22%7D)); // 0
+int%5B%5D set = new int%5Bwords.length%5D;%0A        for (int i = 0; i %3C words.length; i++) %7B%0A            int val = 0;%0A            for (char c : words%5Bi%5D.toCharArray()) %7B%0A                int bit = c - 97;%0A                val %7C= 1 %3C%3C bit;%0A            %7D%0A            set%5Bi%5D = val;%0A        %7D%0A        int max = 0;%0A        for (int i = 0; i %3C set.length; i++) %7B%0A            for (int j = i; j %3C set.length; j++) %7B%0A                int val = set%5Bi%5D & set%5Bj%5D;%0A                if (val == 0) %7B%0A                    max = Math.max(max, words%5Bi%5D.length() * words%5Bj%5D.length());%0A                %7D%0A            %7D%0A        %7D%0A        return max;
 %0A   

Solve problem 318