// ["a","ab","abc","d","cd","bcd","abcd"] 两个串没有重叠部分,最长乘积varmaxProduct=function(words){var max =0for(var i =0; i < words.length; i++){for(var j = i +1; j < words.length; j++){var value =f(words[i], words[j])
max = Math.max(max, value)}}return max
functionf(s1, s2){var set = Array.from([...s2]).join('')var reg =newRegExp(`[${set}]`)var flag = reg.test(s1)if(flag)return0return s1.length * s2.length
}}
使用charCode
functionf(s1, s2){var str1
for(var i =0; i < s1.length; i++){
str1 |=1<<(s1[i].charCodeAt()-'a'.charCodeAt())}var str2
for(var i =0; i < s2.length; i++){
str2 |=1<<(s2[i].charCodeAt()-'a'.charCodeAt())}return!!(str1 & str2)}