1var wordSubsets = function (words1, words2) {2this.count = Array(26).fill(0);3let tmp = Array(26).fill(0);4for (let b of words2) {5tmp = counter(b);6for (let i = 0; i < 26; i++) count[i] = Math.max(count[i], tmp[i]);7}8let list = [];9for (let a of words1) if (isSub(counter(a))) list.push(a);10return list;11};1213function isSub(tmp) {14for (let i = 0; i < 26; i++) if (tmp[i] < this.count[i]) return false;15return true;16}1718function counter(s) {19let tmp = Array(26).fill(0);20for (let c of s) tmp[c.charCodeAt() - 97]++;21return tmp;22}