JS [ Realized it can be solved by KMP after the contest ]
Code\njavascript []\n/* -------------------------------------------------------- */\n/*   ( The Authentic JS CodeBuff ) \t\t\t\t                                
# Code\n```javascript []\n/* -------------------------------------------------------- */\n/*   ( The Authentic JS CodeBuff ) \t\t\t\t                                     \n ___ _                      _              _ \n | _ ) |_  __ _ _ _ __ _ __| |_ __ ____ _ (_)\n | _ \\ \' \\/ _` | \'_/ _` / _` \\ V  V / _` || |\n |___/_||_\\__,_|_| \\__,_\\__,_|\\_/\\_/\\__,_|/ |\n                                        |__/ \n */\n/* ---------------------------------------------------------   */\n/*    Youtube: https://youtube.com/@code-with-Bharadwaj        */\n/*    Portfolio:https://manu-bharadwaj-portfolio.vercel.app/  */\n/* ----------------------------------------------------------- */\n\nvar findPattern = function(text, pattern) {\n    let textLen = text.length;\n    let patternLen = pattern.length;\n    let suffixArr = new Array(patternLen).fill(0);\n    for (let idx = 1; idx < patternLen; idx++) {\n        let prevMatch = suffixArr[idx - 1];\n        while (prevMatch > 0 && pattern[prevMatch] !== pattern[idx]) {\n            prevMatch = suffixArr[prevMatch - 1];\n        }\n        suffixArr[idx] = prevMatch + +(pattern[prevMatch] === pattern[idx]);\n    }\n\n    let matchLengths = new Array(textLen).fill(0);\n    matchLengths[0] = +(text[0] === pattern[0]);\n    for (let idx = 1; idx < textLen; idx++) {\n        let prevMatch = matchLengths[idx - 1];\n        while (prevMatch > 0 && text[idx] !== pattern[prevMatch]) {\n            prevMatch = suffixArr[prevMatch - 1];\n        }\n        matchLengths[idx] = prevMatch + +(text[idx] === pattern[prevMatch]);\n    }\n    return matchLengths;\n};\n\nvar minValidStrings = function(vocab, targetStr) {\n    let targetLen = targetStr.length;\n    let vocabSize = vocab.length;\n    let stepTracker = new Array(targetLen + 1).fill(10 ** 9);\n    stepTracker[0] = 0;\n\n    let lookupMap = Array.from({ length: targetLen }).map(_ => new Set());\n    for (let word of vocab) {\n        let matches = findPattern(targetStr, word);\n        for (let idx = 0; idx < matches.length; idx++) {\n            if (matches[idx] > 0) {\n                lookupMap[idx].add(matches[idx]);\n            }\n        }\n    }\n\n    for (let idx = 0; idx < targetLen; idx++) {\n        let matchSet = lookupMap[idx];\n        for (let matchLength of matchSet) {\n            stepTracker[idx + 1] = Math.min(stepTracker[idx + 1], stepTracker[idx + 1 - matchLength] + 1);\n        }\n    }\n\n    return stepTracker[targetLen] === 10 ** 9 ? -1 : stepTracker[targetLen];\n};\n\n```
['JavaScript']