2
* @param {string[]} stickers3
* @param {string} target8
var minStickers = function (stickers, target) {13
const getStringDiff = (str1, str2) => {15
if (str1.includes(c)) str1 = str1.replace(c, "");22
function calcStickers(restStr) {23
// if(restStr === "") return 0; <-- without memoization24
if (dp.has(restStr)) return dp.get(restStr);27
for (let s of stickers.filter((s) => s.includes(restStr[0]))) {28
// if current sticker does not contain the FIRST char, continue29
let str = getStringDiff(restStr, s); //aabbc - bc = aab30
res = Math.min(res, 1 + calcStickers(str)); // RECURSE.... calculate min stickers for the remaining letters.. try combination for all strings and get min33
dp.set(restStr, res === Infinity || res === 0 ? -1 : res); //Memoize the result in dp;34
return dp.get(restStr);35
// return res; <-- without memoization37
return calcStickers(target);