2
* @param {string[]} words3
* @param {string} target6
var numWays = function (words, target) {7
const targetLength = target.length;8
const wordsLength = words.length;9
const wordLength = words[0].length;10
const mem = Array(targetLength)12
.map(() => Array(targetLength));14
const count = Array(26)17
for (let i = 0; i < wordsLength; i++) {18
for (let j = 0; j < wordLength; j++) {19
if (!count[words[i].charCodeAt(j) - 97][j]) {20
count[words[i].charCodeAt(j) - 97][j] = 0;22
count[words[i].charCodeAt(j) - 97][j]++;26
const dp = (targetIndex, minIndex) => {27
if (targetIndex === targetLength) {30
if (wordLength - minIndex < targetLength - targetIndex) return 0;31
if (mem[targetIndex][minIndex] !== undefined)32
return mem[targetIndex][minIndex];35
for (let i = minIndex; i < wordLength; i++) {36
if (count[target.charCodeAt(targetIndex) - 97][i]) {38
Number(count[target.charCodeAt(targetIndex) - 97][i]) *39
dp(targetIndex + 1, i + 1);44
mem[targetIndex][minIndex] = res;