Clean solution with comments and explanation. JS.
Intuition\nSimilar to other variants focused on prefix and suffix arrays, but this one makes a bit more sense to me.\n\nA key detail that I missed at the very b
# Intuition\nSimilar to other variants focused on prefix and suffix arrays, but this one makes a bit more sense to me.\n\nA key detail that I missed at the very beginning is this is *subsequence* not a *substring*. \n\nWe are looking for a way to drop characters from `t` such that the same sequence of characters appears in `s`. But it doesn\'t have to be an unbroken sequence, it\'s not a substring.\n\n# Approach\n- Iterate forward through `s` and do two things:\n  - Increment the prefix array when we consume a matching character from `t`\n  - Carry that consumed count forward to the end of the prefix array and keep incrementing as needed.\n- Do the same thing in reverse for the suffix array.\n- Then, use these prefix and suffix arrays to find minimum of the following:\n  - Scan both prefix and suffix and find the minimum score that uses both prefix and suffix at any point.\n  - Check if the min score is only using prefix (last prefix element)\n  - Check if the min score is only using suffix (first suffix element)\n- Lastly, if that number is less than zero, there is no match. Return 0.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```javascript []\n/**\n * @param {string} s\n * @param {string} t\n * @return {number}\n */\nvar minimumScore = function(s, t) {\n    const sLen = s.length;\n    const tLen = t.length;\n\n    // \n    const prefix = Array(sLen).fill(0);\n    const suffix = Array(sLen).fill(0);\n\n    let j = 0;\n\n    // Build prefix match array, with t characters consumed up until that point in s\n    for (let i = 0; i < sLen; i++) {\n        if (s[i] === t[j]) {\n            prefix[i]++;\n            j++;\n        }\n\n        if (i > 0) {\n            prefix[i] += prefix[i - 1];\n        }\n    }\n\n    j = tLen - 1;\n    // Build suffix match array, with t characters consumed up until that point in s\n    for (let i = sLen - 1; i >= 0; i--) {\n        if (s[i] === t[j]) {\n            suffix[i]++;\n            j--;\n        }\n\n        if (i < sLen - 1) {\n            suffix[i] += suffix[i + 1];\n        }\n    }\n\n    let minScore = Infinity;\n\n    // Find min that involves prefix and suffix\n    for (let i = 0; i < sLen - 1; i++) {\n        const suffixAndPrefixLen = prefix[i] + suffix[i + 1];\n        minScore = Math.min(minScore, tLen - suffixAndPrefixLen);\n    }\n\n    // Check if min is prefix only\n    minScore = Math.min(minScore, tLen - prefix[sLen - 1]);\n    // Check if min is suffix only\n    minScore = Math.min(minScore, tLen - suffix[0]);\n\n    return Math.max(0, minScore);\n};\n```
['JavaScript']