题目
解题思路

作者:tong-zhu
链接:https://leetcode-cn.com/problems/maximum-product-of-word-lengths/solution/tong-ge-lai-shua-ti-la-zhao-dao-ti-mu-de-y37h/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
解题代码
class Solution {public int maxProduct(String[] words) {int[] bits = new int[words.length];for(int i = 0; i< words.length; i++) {char[] chars = words[i].toCharArray();for(int j = 0; j < chars.length; j++) {bits[i] |= 1 << (chars[j] - 'a' );}}int max = 0;for(int i = 0; i < bits.length; i++ ) {for(int j = i + 1; j < bits.length; j++ ) {if( (bits[i] & bits[j] ) == 0 ) {max = Math.max(max, (words[i].length() * words[j].length()) );}}}return max;}}
